Lab Tutorial - 1
- Due No Due Date
- Points 10
- Submitting a file upload
Sample Format for file upload.docx
1 : Write a program to print “Hello World”.
2 : Design your profile page as given below.
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
Name: Ramesh Tamkuity
DOB: 15/10/1991
Address: 4, xyx society,
Kalawad Road
City: Rajkot
Pincode: 360 001
State: Gujarat
Country: India
Email: abc@ymail.com
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
3 : Find out whether the given number is odd or even.
4 : Rearrange the given code to correct the program. The resultant program will be to input a number and print whether the given number is odd or even.
namespace ConsoleApplication1
{
{
static void Main(string[] args)
{
int x;
Console.WriteLine("Enter Number : ");
x = Convert.ToInt32(str);
Console.WriteLine("Number is Even");
else
Console.Read();
string str = Console.ReadLine();
if (x % 2 == 0)
Console.WriteLine("Number is Odd");
}
}
}
class Program
using System;
Output:
Enter Number: 10
Number is Even
5 : Write output of the program. Also write comment for each line for the following code.
using System;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int n,fact=1;
Console.WriteLine("Enter Number : ");
string str = Console.ReadLine();
n = Convert.ToInt32(str);
for (int i = 1; i <= n; i++)
{
fact = fact * i;
}
Console.WriteLine("Factorial : {0}",fact);
Console.Read();
}
}
}
6 : Write missing statement to get the desired output.
using System;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int a,b,c,result;
Console.Write("Enter Number 1: ");
//Missing statement
a = Convert.ToInt32(str);
Console.Write("Enter Number 2 : ");
//Missing statement
b = Convert.ToInt32(str);
Console.Write("Enter Number 3 : ");
str = Console.ReadLine();
//Missing statement
result = Sum(a, b, c);
//Missing statement
Console.Read();
}
static int Sum(int x, int y, int z)
{
int res;
res = x+y+z;
return res;
}
}
}
Output:
Enter Number 1 : 10
Enter Number 2 : 20
Enter Number 3 : 30
Sum : 60
7 : Predict and write the output of the given code.
using System;
namespace While_Loop
{
class Program
{
static void Main(string[] args)
{
int num1,res, i;
Console.WriteLine("Enter a number");
num1 = Convert.ToInt32(Console.ReadLine());
i = 1; //Initialization
//Check whether condition matches or not
while (i <= 10)
{
res = num1 * i;
Console.WriteLine("{0} x {1} = {2}", num1, i, res);
i++; //Increment by one
}
Console.ReadLine();
}
}
}
8 Write a program to convert given name in upper characters.
INPUT : John F Kennedy
OUTPUT: JOHN F KENNEDY
9 Write a Program to convert given name in toggle case.
INPUT : JoHn F kEnNedy
OUTPUT: jOhN f KeNneDY
10 Write a Program which accepts mobile no as a string from the user and converts the last 5 digits into X.
INPUT : 1234567890
OUTPUT: 12345XXXXX
11 Write a Program which accepts name and gender from the user. Here, gender may have only 1 character, M or F.
Based on the gender prefix the name Mr. & Ms.
NAME : Hillary Clinton
GENDER : F
12 Write a Program which accepts name from the user and prints the same
INPUT : Winston Churchill
OUTPUT: Winston Churchill
13 Write a Program to prints the following series
0 1 1 2 3 5 8 13 21 34 55
14 Write a Program which accepts no from the user and print the same in words.
INPUT : 98732
OUTPUT: Nine Eight Seven Three Two
15 Write a Program to check whether the given no is Armstrong no or not.
Find Rubric