Professional Documents
Culture Documents
VISUAL PROGRAMMING
{
int a, b, c = 0;
Console.WriteLine("Enter two number");
a = int.Parse(Console.ReadLine());
b = int.Parse(Console.ReadLine());
c = a;
a = b;
b = c;
System.Console.WriteLine("The Swaped Value of A={0} B=
{1}", a, b);
Console.ReadKey();
{
double Year, Month;
Console.WriteLine("Enter years:");
Year = double.Parse(Console.ReadLine());
Month = Year * 12;
System.Console.WriteLine("Num of months in your given
year:{0}", Month);
Console.ReadKey();
}
8. Write a program to get name and age of a person. Calculate the age in
months and number of days with the name of person.
{
String Name;
int Year, Month, Days;
Console.WriteLine("Enter Your Name:");
Name = Console.ReadLine();
Console.WriteLine("Enter Your Age In Years:");
Year = int.Parse(Console.ReadLine());
Month = Year * 12;
Days = Year * 365;
Console.WriteLine("Your Name:{0} \n Your Age in Months:{1}
\n Your Age in Days :{2}", Name, Month, Days);
Console.ReadKey();
{
double F, C;
Console.WriteLine(" Enter Temprature in Fahrenheit=");
F = double.Parse(Console.ReadLine());
C = ((F - 32) * 5) / 9;
Console.WriteLine("Temprature In Celsius ={0}", C);
Console.ReadKey();
{
int j, k = 3;
j = int.Parse(Console.ReadLine());
j = j % k;
if (j == 0)
{
Console.WriteLine("the number is divisible by three");
}
else
{
Console.WriteLine("the number is not divisible by
three");
}
Console.ReadKey();
}
12. Write a program to input a number. If the number is prime number then
print the message on the screen that prime number.
{
int n, i;
Console.WriteLine("Enter a positive integer:");
n = int.Parse(Console.ReadLine());
for (i = 2; i <= n / 2; ++i)
{
if (n % i == 0)
{
Console.WriteLine("Not prime");
break;
}
}
Console.ReadKey();
}
13. Write a program to calculate the electric bill. The rates of electricity per
unit are as follow:
If the units consumed are equal or less than 300. Then the cost is Rs.
3/- per unit.
If units consumed are more than 300, then the cost is Rs. 3.5/- per unit
and a surcharge of 5% of the bill is added.
{
double n, m, o;
Console.WriteLine("Enter the consumed units=");
n = double.Parse(Console.ReadLine());
if (n <= 300)
{
m = n * 3;
Console.WriteLine("You bill = {0}", m);
}
else if (n > 300)
{
m = n * 3.5;
= (m / 100) * 5;
Console.WriteLine("You bill = {0}", 0);
}
Console.ReadKey();
}
14. Write a program to input two values from the keyboard and then to print
the larger number on the computer screen.
{
double n, m;
Console.WriteLine("Enter 1st number=");
n = D.Parse(Console.ReadLine());
Console.WriteLine("Enter 2nd number=");
m = double.Parse(Console.ReadLine());
if (n > m)
{
Console.WriteLine("n is greater");
}
else if (m > n)
{
Console.WriteLine("m is greater");
}
else if (m = n)
{
Console.WriteLine("Equal to each other");
}
Console.ReadKey();
}
15. Write a program to calculate the net pay of an employee. Input the basic
pay and calculate the net pay as follow:
Conveyance allowance is Rs. 96/- if basic pay is less than Rs. 5000/-. It
is Rs. 193/- if then basic pay is more than Rs. 5000/-.
16. Write a program to find out the grade of a student based on the marks
obtained in three subjects. The grade is calculated as:
}
Console.ReadKey();