voting program using if-else in c#.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CP_Looping_Paractise
{
class Program
{
static void Main(string[] args)
{
char rep;
string name;
int age, tv = 0;
do
{
Console.WriteLine("Enter Age");
age = Convert.ToInt32(Console.ReadLine());
if (age >= 18)
{
Console.WriteLine("Enter name of person");
name = Convert.ToString(Console.ReadLine());
tv++;
}
else
{
Console.WriteLine("your age is short");
}
Console.WriteLine("do you want to add more");
rep = Convert.ToChar(Console.ReadLine());
}
while (rep =='y' || rep == 'Y');
Console.WriteLine("Total vote{0}",tv);
}
}
}
Comments
Post a Comment