Sunday 3 December 2017

C# Program to Illustrate the Concept of Goto


Code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Example
{
    class Program
    {
        static void Main(string[] args)
        {
            int no, per, option;
            float ans;
        loop:
            Console.Write("Enter a Number :\t");
            no = Convert.ToInt32(Console.ReadLine());
            Console.Write("\nEnter Percentage Value : \t");
            per = Convert.ToInt32(Console.ReadLine());
            ans = (float)(no * per) / 100;
            Console.WriteLine("Percentage Value is:\t{0}", ans);
            Console.Write("\nCalculate again press 1.   To quit press digit:\t");
            option = Convert.ToInt32(Console.ReadLine());
            if (option == 1)
            {
                goto loop;
            }
            Console.WriteLine("Press Enter for quit");
            Console.ReadLine();
        }
    }
}


Output:

Enter a number : 320
Enter Percentage Value : 10
Percentage value is : 32
Calculate again press 1. To quit Press digit: 1
Enter a number : 730
Enter Percentage Value: 10
Percentage value is: 73
Calculate again press 1. To quit press digit: 6
Press Enter for quit


More C# Programs:





















100+ Best Home Decoration Ideas For Christmas Day 2019 To Make Home Beautiful

Best gifts for Christmas Day | Greeting cards for Christmas Day | Gift your children a new gift on Christmas day This Christmas d...