Professional Documents
Culture Documents
D.O.S-07/09/2010
STUDENT’S SIGNATURE
AMITA RAI
Evaluator comments…………….
Q.2: - Write a Program to Find Largest of three No’s. Also make these no’s in
increasing order.
ANS: - using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace test1
{
class Program
{
static void Main(string[] args)
{
int [ ] arr = new int[3];
Console.WriteLine("Enter x");
arr[0] = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Enter y");
arr[1] = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Enter z");
a[2] = Convert.ToInt32(Console.ReadLine());
if (arr[0] > arr[1] && arr[0] > arr[2])
{
Console.WriteLine("The largest no is " + arr[0]);
}
else if (arr[1] > arr[0] && arr[1] > arr[2])
{
Console.WriteLine("The largest no is " + arr[1]);
}
else
{
Console.WriteLine("The largest no is " + arr[2]);
}
for (int x = 0; x < arr.Length; x++)
{
for (int y = 0; y < arr.Length - 1; y++)
{
if (arr[y] > arr[y + 1])
{
int tem;
tem = arr[y + 1];
arr[y + 1] = arr[y];
arr[y] = tem;
}
}
}
for (int x = 0; x < arr.Length; x++)
Console.WriteLine(arr[x]);
Console.ReadLine();
}
}
}
Q.4: - Write a program to input your name and display output on console
window and message box?
ANS: -
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace test2
{
class Program
{
static void Main(string[ ] args)
{
string s;
Console.WriteLine("Enter any string");
s = Console.ReadLine();
Console.WriteLine(" string is = " +s);
Console.ReadLine();
}
}
}
Q.1: - Write a Program to Print Sale Bill of a Garment House, with following
terms of discount on each product :-
class Program
{
static void Main(string[ ] args)
{
Console.WriteLine(" bill of garment house");
Int price, q;
Console.WriteLine("Enter Quantity:");
q = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Enter Maximum Price:");
price = Convert.ToInt32(Console.ReadLine());
Q.2: - Write a program to find paired numbers in the series from 1 to 1000
using for control statement.
ANS: -
using System;
using System.Collections.Generic;
using System.Text;
namespace test4
{
class Program
{
static void Main(string[ ] args)
{
int x,y,z,n;
n = i;
x= n % 10;
n = n / 10;
y = n;
if (x == y)
Console.WriteLine(i);
n= i;
x = n % 10;
n = n / 10;
y= n % 10;
n = n / 10;
z= n;
if (x == y && x == z)
{
Console.WriteLine(i);
Console.ReadLine();
}
}
}
class Program
{
static void Main(string[ ] args)
{
Console.WriteLine("Enter the string");
string s=Console.ReadLine();
int len=s.Length;
int up=0,cha=0,lw=0,num=0,sp=0,ss=0;
char[] cc=new char[len];
for (int i = 0; i < s.Length; i++)
{
cc[i] = s[i];
}
int ascii;
for (int i = 0; i < len; i++)
{
ascii = cc[i];
if (ascii >= 65 && ascii <= 90)
{
up++;
cha++;
}
else if (ascii >= 97 && ascii <= 122)
{
lw++;
cha++;
}
else if (ascii >= 48 && ascii <= 57)
{
num++;
}
else if (ascii == 32)
{
sp++;
}
else
{
ss++;
}
}
Console.WriteLine("number of words is"+len);
Console.WriteLine(“ number of character is"+cha);
Console.WriteLine(" number of upper case is"+up);
Console.WriteLine("Lower case"+lw);
Console.WriteLine("numbers is "+num);
Console.WriteLine("Spaces are "+sp);
Console.WriteLine("Special Character are"+ss);
Console.ReadLine();
}
}
}
Q.4: - Write a Program that finds the location and number of occurrences of
a particular number in an array.
ANS: - using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace test5
{
class Program
{
static void Main(string[] args)
{
}
foreach (int i in arr)
{
Console.WriteLine(i);
}
Console.ReadLine();
}
}
}