Write a program to display the highest of any 10 numbers entered. (Duration: 30 min)
using System;
using System.Collections.Generic;
using System.Text;
namespace largest_loop
{
class program
{
static void Main(string[]args)
{
int ctr, nNum1, max=0;
for (ctr=0; ctr<=9; ctr++)
{
Console.WriteLine("Enter the numbers"+(chr+1));
nNum1 = Console.ToInt32(Console.ReadLine());
if (nNum1>max)
max=nNum1;
}
Console.WriteLine(max);
Console.ReadLine();
}
}
}
using System.Collections.Generic;
using System.Text;
namespace largest_loop
{
class program
{
static void Main(string[]args)
{
int ctr, nNum1, max=0;
for (ctr=0; ctr<=9; ctr++)
{
Console.WriteLine("Enter the numbers"+(chr+1));
nNum1 = Console.ToInt32(Console.ReadLine());
if (nNum1>max)
max=nNum1;
}
Console.WriteLine(max);
Console.ReadLine();
}
}
}
Write a program to enter a number from 1 to 7 and display the corresponding day of the week. Hint: 1 = Monday (Duration: 30 min)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace number_from_1_to_7
{
class Day
{
static void Main(string[] args)
{
int num;
Console.WriteLine("Entre a number");
num = Convert.ToInt32(Console.ReadLine());
switch (num)
{
case 1:
Console.WriteLine("Monday");
break;
case 2:
Console.WriteLine("Tuesday");
break;
case 3:
Console.WriteLine("Wednesday");
break;
case 4:
Console.WriteLine("Thursday");
break;
case 5:
Console.WriteLine("friday");
break;
case 6:
Console.WriteLine("Saturday");
break;
case 7:
Console.WriteLine("Sunday");
break;
default:
Console.WriteLine("Invalid Number");
break;
}
}
}
}
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace number_from_1_to_7
{
class Day
{
static void Main(string[] args)
{
int num;
Console.WriteLine("Entre a number");
num = Convert.ToInt32(Console.ReadLine());
switch (num)
{
case 1:
Console.WriteLine("Monday");
break;
case 2:
Console.WriteLine("Tuesday");
break;
case 3:
Console.WriteLine("Wednesday");
break;
case 4:
Console.WriteLine("Thursday");
break;
case 5:
Console.WriteLine("friday");
break;
case 6:
Console.WriteLine("Saturday");
break;
case 7:
Console.WriteLine("Sunday");
break;
default:
Console.WriteLine("Invalid Number");
break;
}
}
}
}
No comments:
Post a Comment