SlideShare a Scribd company logo
1 of 12
Download to read offline
Programs Are Compiled By: Yasir Ahmed Khan | yasirahmedkhan@ymail.com | 03337015014
CONSOLE PROGRAMSCONSOLE PROGRAMSCONSOLE PROGRAMSCONSOLE PROGRAMS
By: Yasir A k
PROGRAM 01: (Print Name)
static void Main(string[] args)
{
Console.WriteLine("Welcome");
//Console is a built-in class that contains the methods for displaying messages on the
// screen and getting input from the keyboard.
string name;
Console.Write("Enter Your Name: ");
name = Console.ReadLine(); // Input
Console.WriteLine("Your Name Is: " + name);
Console.ReadKey(); // to hold output like getch()
}
PROGRAM 02: (Print Integer)
static void Main(string[] args)
{
int myInteger;
string myString;
myInteger = 17;
myString = ""My Integer" is";
Console.WriteLine(myString +" "+ myInteger);
Console.ReadKey();
}
PROGRAM 03: (Addition, Subtraction, Multiplication and Division of a Number)
static void Main(string[] args)
{
double firstNumber, secondNumber;
string userName;
Console.WriteLine("Enter your Name: ");
userName = Console.ReadLine();
Console.WriteLine("Welcome "+ userName);
Console.WriteLine("Now give me a number:");
firstNumber = Convert.ToDouble(Console.ReadLine());
Console.WriteLine("Now give me another number:");
secondNumber = Convert.ToDouble(Console.ReadLine());
Console.WriteLine("The sum of {0} and {1} is {2}.", firstNumber,
secondNumber, firstNumber + secondNumber);
Console.WriteLine("The result of subtracting {0} from {1} is {2}.",
secondNumber, firstNumber, firstNumber - secondNumber);
Console.WriteLine("The product of {0} and {1} is {2}.", firstNumber,
secondNumber, firstNumber * secondNumber);
Console.WriteLine("The result of dividing {0} by {1} is {2}.",
firstNumber, secondNumber, firstNumber / secondNumber);
Console.WriteLine("The remainder after dividing {0} by {1} is {2}.",
firstNumber, secondNumber, firstNumber % secondNumber);
Console.ReadKey();
}
Programs Are Compiled By: Yasir Ahmed Khan | yasirahmedkhan@ymail.com | 03337015014
PROGRAM 04: (Marks Sheet)
static void Main(string[] args)
{
int phy, maths,eng,cp,isl;
int total;
double per;
Console.WriteLine("nttt MARKS CERTIFICATE ");
Console.Write("nEnter Physics Marks:");
phy = Convert.ToInt32(Console.ReadLine());
Console.Write("nEnter Mathematics Marks:");
maths = Convert.ToInt32(Console.ReadLine());
Console.Write("nEnter English Marks: ");
eng = Convert.ToInt32(Console.ReadLine());
Console.Write("nEnter Programming Marks:");
cp = Convert.ToInt32(Console.ReadLine());
Console.Write("nEnter Islamiat Marks:");
isl = Convert.ToInt32(Console.ReadLine());
total = phy + maths+ isl + cp +eng;
per = (total * 100) / 550;
Console.WriteLine("Total is: "+Convert.ToInt32(total));
Console.WriteLine("Percentage is: {0} %" , Convert.ToDouble(per));
Console.WriteLine("n");
if (per > 80.0)
Console.WriteLine("You Got Grade: A1 ");
else
if (per > 70.0)
Console.WriteLine("You Got Grade: A");
else
if (per > 60.0)
Console.WriteLine("You Got Grade: B");
else
if (per > 50.0)
Console.WriteLine("You Got Grade: C");
else
if (per < 49.9)
Console.WriteLine("Your Fail");
Console.WriteLine("nnttThis Software is Developed By: Yasir Ahmed Khan");
Console.ReadKey();
}
PROGRAM 05: Table using For Loop
static void Main(string[] args)
{
int tab_no;
Console.WriteLine("ntttTable Generatorn");
Console.Write("Enter Table No: ");
tab_no = Convert.ToInt32(Console.ReadLine());
for(int x=1; x<=10;x++)
{
Console.WriteLine("n{0} * {1} = {2}",tab_no,x,(tab_no*x) );
}
Console.ReadKey();
}
Programs Are Compiled By: Yasir Ahmed Khan | yasirahmedkhan@ymail.com | 03337015014
PROGRAM 06: Sum of Two Number’s
{
int number1, number2, sum;
Console.Write("Enter First No:");
number1 = Convert.ToInt32(Console.ReadLine());
Console.Write("Enter Second No:");
number2 = Convert.ToInt32(Console.ReadLine());
sum = number1 + number2;
Console.Write("Sum is " + sum);
Console.WriteLine("nnttt This Program is Written By: Yasir Ahmed Khan");
Console.ReadKey();
}
PROGRAM 07: Cities Temperature
{
double nshah, khi, hyd, multan, isd, lahore, average;
Console.WriteLine("nnttt AVERAGE TEMPERATURE");
Console.Write("nEnter Temperature of Nawabshah City :");
nshah = Convert.ToDouble(Console.ReadLine());
Console.Write("nEnter Temperature of Hyderabad City :");
hyd = Convert.ToDouble(Console.ReadLine());
Console.Write("nEnter Temperature of Multan City :");
multan = Convert.ToDouble(Console.ReadLine());
Console.Write("nEnter Temperature of Islamabad City :");
isd = Convert.ToDouble(Console.ReadLine());
Console.Write("nEnter Temperature of Lahore City :");
lahore = Convert.ToDouble(Console.ReadLine());
Console.Write("nEnter Temperature of Karachi City :");
khi = Convert.ToDouble(Console.ReadLine());
average = (nshah + hyd + multan + isd + lahore) / 6;
Console.WriteLine("nnAVERAGE TEMPERATURE IS: " + average);
Console.WriteLine("nnttt This Program is Written By: Yasir Ahmed Khan");
Console.ReadKey();
}
PROGRAM 08: Square & Cube of a Number
{
int num,square,cube,sq_root;
Console.Write("Enter Number: ");
num = Convert.ToInt32(Console.ReadLine());
square = num * num;
cube = square * num;
Console.WriteLine("nn Square is " + square);
Console.WriteLine("nn Cube is " + cube);
Console.WriteLine("nnttt This Program is Written By: Yasir Ahmed Khan");
Console.ReadKey();
}
Programs Are Compiled By: Yasir Ahmed Khan | yasirahmedkhan@ymail.com | 03337015014
PROGRAM 09: Number Compression
{
int num1, num2;
Console.Write("nntt COMPARISSION B/W TWO NUMBER's");
Console.Write("nnEnter Ist Number ");
num1 = Convert.ToInt32(Console.ReadLine());
Console.Write("Enter IInd Number ");
num2 = Convert.ToInt32(Console.ReadLine());
if (num1 == num2)
Console.WriteLine(num1+" is Equals to "+num2);
if(num1>num2)
Console.WriteLine(num1 + " is Greater Than " + num2);
if (num1 < num2)
Console.WriteLine(num1 + " is Less Than " + num2);
if (num1 != num2)
Console.WriteLine(num1 + " is Not Equals to " + num2);
if (num1 >= num2)
Console.WriteLine(num1 + " is Greater Than or equals to " + num2);
if (num1 <= num2)
Console.WriteLine(num1 + " is Less Than or equals to " + num2);
Console.WriteLine("nnttt This Program is Written By: Yasir Ahmed Khan");
Console.ReadKey();
}
PROGRAM 10: Kilo Meter to meter
{
int meter, km;
Console.Write("nntt Enter Value in Kilo Meter ");
km = Convert.ToInt32(Console.ReadLine());
meter = km * 1000 ;
Console.Write("nntt The Value in Meter Is " + meter);
Console.WriteLine("nnttt This Program is Written By: Yasir Ahmed Khan");
Console.ReadKey();
}
Programs Are Compiled By: Yasir Ahmed Khan | yasirahmedkhan@ymail.com | 03337015014
PROGRAM 11: Age Analyzer
{
int year, month,day;
Console.Write("nntt Enter The Age in Year ");
year = Convert.ToInt32(Console.ReadLine());
Console.Write("nntt Enter The Age in MOnth ");
month = Convert.ToInt32(Console.ReadLine());
day = year * 365 + month *30 ;
Console.Write("nntt Your " + day + " days old");
Console.WriteLine("nnttt This Program is Written By: Yasir Ahmed Khan");
Console.ReadKey();
}
PROGRAM 12: KB to Byte Conversion
{
int bit,kb;
Console.Write("nntt Enter The Data Size in Kilo Bytes ");
kb = Convert.ToInt32(Console.ReadLine());
bit = kb * 1024 ;
Console.Write("nntt Your Data Size is " + bit + " Byte ");
Console.WriteLine("nnttt This Program is Written By: Yasir Ahmed Khan");
Console.ReadKey();
}
PROGRAM 13: Temperature Conversion
static void Main(string[] args)
{
//Temperature of a city in Fahrenheit degrees is input through the keyboard.
//Write a program to convert this temperature into Centigrade degrees.
double temp_f, temp_c;
Console.WriteLine("Enter Your City Temperature: ");
temp_f = double.Parse(Console.ReadLine());
temp_c = (temp_f - 32) * 5 / 9;
Console.WriteLine("Temperature in Celsius is : " + temp_c);
Console.WriteLine("nnttt This Program is Written By: Yasir Ahmed Khan");
Console.ReadKey();
}
Programs Are Compiled By: Yasir Ahmed Khan | yasirahmedkhan@ymail.com | 03337015014
PROGRAM 14: Conversion of Length
static void Main(string[] args)
{
//The distance between two cities (in km.) is input through the keyboard.
//Write a program to convert and print this distance in meters, feet, inches and
centimeters.
double km, m, feet, inches, centimeter;
Console.Write("Enter Distance B/w Two Cities in Kilo Meter: ");
km = double.Parse(Console.ReadLine());
m = km * 1000;
feet = m * 3.28084;
centimeter = m * 100;
inches = m * 39.37008;
Console.WriteLine("Distance in Km : " + km);
Console.WriteLine("Distance in m : " + m);
Console.WriteLine("Distance in feet : " + feet);
Console.WriteLine("Distance in centimeter : " + centimeter);
Console.WriteLine("Distance in inches : " + inches);
Console.WriteLine("nnttt This Program is Written By: Yasir Ahmed Khan");
Console.ReadKey();
}
PROGRAM 15: Salary Sheet
static void Main(string[] args)
{
//Ramesh’s basic salary is input through the keyboard.
//His dearness allowance is 40% of basic salary, and house rent allowance is 20% of
basic salary.
//Write a program to calculate his gross salary.
int basic_salary;
double dearnesss_allowance, house_rent_allowance, gross_salary;
Console.Write("nn ttPlease Enter Your Basic Salary: ");
basic_salary = int.Parse(Console.ReadLine());
dearnesss_allowance = (basic_salary * 0.4);
house_rent_allowance= (basic_salary * 0.2);
gross_salary = dearnesss_allowance + house_rent_allowance + basic_salary;
Console.WriteLine("n ttBasic Salary: " + basic_salary);
Console.WriteLine("n ttDearness Allowance: " + dearnesss_allowance);
Console.WriteLine("n ttHouse Rent Allowance: " + house_rent_allowance);
Console.WriteLine("n ttGross Salary: " + gross_salary);
Console.WriteLine("nnttt This Program is Written By: Yasir Ahmed Khan");
Console.ReadKey();
}
Programs Are Compiled By: Yasir Ahmed Khan | yasirahmedkhan@ymail.com | 03337015014
PROGRAM 16: Age Analyzer
static void Main(string[] args)
{
int age, days, month;
Console.WriteLine("give your age progarme will convert it into days");
Console.WriteLine("give your age in years");
age = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("give your age in months");
month = Convert.ToInt32(Console.ReadLine());
days = age * 365 + month * 30;
Console.WriteLine("conversion successful,the days will be " + days + " in " + age + "
year " + "and" + month+ "months");
}
PROGRAM 17: Modulus / Absolute
static void Main(string[] args)
{
// Finding Absoulute Value or Modulus
int modulus_no;
Console.WriteLine("Enter No Which u want to want to find out modulus");
modulus_no = int.Parse(Console.ReadLine());
Console.WriteLine(Math.Abs(modulus_no));
Console.ReadKey();
}
PROGRAM 18: Largest Number
{
//Finding Greater Number B/w Three Number's
int n1, n2, n3;
Console.WriteLine("Enter 1st Number: ");
n1 = int.Parse(Console.ReadLine());
Console.WriteLine("Enter 2nd Number: ");
n2 = int.Parse(Console.ReadLine());
Console.WriteLine("Enter 3rd Number: ");
n3 = int.Parse(Console.ReadLine());
if (n1 > n2 && n1 > n3)
Console.WriteLine("n{0} is greater than {1} & {2}", n1, n2, n3);
else
if (n2 > n3 && n2 > n1)
Console.WriteLine("n{0} is greater than {1} & {2}", n2, n1, n3);
else
if (n3 > n1 && n3 > n2)
Console.WriteLine("n{0} is greater than {1} & {2}", n3, n2, n1);
else
Console.WriteLine("Number's Are Equals");
Console.ReadKey();
}
Programs Are Compiled By: Yasir Ahmed Khan | yasirahmedkhan@ymail.com | 03337015014
PROGRAM 18: Book Shop
{
int choice,engchoice,pchoice,dchoice;
Console.WriteLine("Welcome In Liberty Books Pvt Ltd. nnn Please Enter Which Subject Book You
Want To Buy nnn1. English n2. Programming n3. Data Basen");
Console.WriteLine("Enter Choice B/w 1-3");
choice = Convert.ToInt32(Console.ReadLine());
if (choice == 1)
{
Console.WriteLine("Now , n Please Enter Which Book You Want To Buy nnn1. English By
Michel John n2. English By Oxfor Printing Press n3. English Dictonary hn");
Console.WriteLine("Enter B/w 1-3");
engchoice = Convert.ToInt32(Console.ReadLine());
if (engchoice == 1)
{
Console.WriteLine("English By Michel John price is $ 45"); Console.ReadKey();
}
if (engchoice == 2)
{
Console.WriteLine("English By Oxfor Printing Press price is $ 55"): Console.ReadKey();
}
if(engchoice==3)
{
Console.WriteLine("English Dictonary Price is $ 10"); Console.ReadKey();
}
else Console.WriteLine("Invalid Range"); Console.ReadKey();
}
if(choice==2)
{
Console.WriteLine("Now , n Please Enter Which Book You Want To Buy nnn1. C Programming n2. C#
Programming n3. Java n"); Console.WriteLine("Enter B/w 1-3");
pchoice = Convert.ToInt32(Console.ReadLine());
if (pchoice == 1)
{
Console.WriteLine("C Programming Book price is $ 45"); Console.ReadKey();
}
if (pchoice == 2)
{
Console.WriteLine("C# Programming Book Press price is $ 55"); Console.ReadKey();
}
if(pchoice==3)
{
Console.WriteLine("Java Programming Book Price is $ 10"); Console.ReadKey();
}
else Console.WriteLine("Invalid Range");
}
if (choice == 3)
{
Console.WriteLine("Now , n Please Enter Which Book You Want To Buy nnn1. Basic Data Base
n2. Oracle 10g n3. My Bank DataBase n");
Console.WriteLine("Enter B/w 1-3");
dchoice = Convert.ToInt32(Console.ReadLine());
if (dchoice == 1)
{
Console.WriteLine("Basic Database Book price is $ 45"); Console.ReadKey();
}
if (dchoice == 2)
{
Console.WriteLine("Oracle 10.G Book Press price is $ 55"); Console.ReadKey();
}
if (dchoice == 3)
{
Console.WriteLine("My Bank Database Book Price is $ 10"); Console.ReadKey();
}
else Console.WriteLine("Invalid Range");}
else { Console.WriteLine("Invalid Range"); }
Console.WriteLine("nn This Program is Write By: Yasir Ahmed Khan");
Programs Are Compiled By: Yasir Ahmed Khan | yasirahmedkhan@ymail.com | 03337015014
}
PROGRAM 19: Area Of Square
{
int width,height,area;
Console.WriteLine("Enter Width:");
width = Int.Parse(Console.ReadLine());
Console.WriteLine("Enter Height:");
height = Int.Parse(Console.ReadLine());
area = width * height;
Console.WriteLine("Area of Square is "+area);
}
PROGRAM 20: (Area Of Circumference)
{
double radius,area;
Console.WriteLine("Enter Radius:");
radius = Double.Parse(Console.ReadLine());
area = radius * 3.14;
Console.WriteLine("Area of circumference is "+area);
}
PROGRAM 21: (Alpha , Beta , Theta )
static void Main(string[] args)
{
Double theta;
Console.WriteLine("give any angle to fint its value");
theta=Convert.ToInt32(Console.ReadLine());
{
Console.WriteLine("Sine of " + theta + " is " +
Math.Sin(theta));
Console.WriteLine("Cosine of " + theta + " is " +
Math.Cos(theta));
Console.WriteLine("Tangent of " + theta + " is " +
Math.Tan(theta));
Console.WriteLine();
}
PROGRAM 22: (Table With Start and Ending Point )
static void Main(string[] args)
{
Console.WriteLine("give table no: which you want");
int a = int.Parse(Console.ReadLine());
Console.WriteLine("give starting point of table");
int b = int.Parse(Console.ReadLine());
Console.WriteLine("give ending point of table");
int c = int.Parse(Console.ReadLine());
for (int d = a; d <= c; d++)
Console.WriteLine(a + "*" + d + "="+(a * d)) }
Programs Are Compiled By: Yasir Ahmed Khan | yasirahmedkhan@ymail.com | 03337015014
PROGRAM 23: (Sun to Earth Distance )
static void Main(string[] args)
{
long inches;
long miles;
miles = 93000000; // 93,000,000 miles to the sun
// 5,280 feet in a mile, 12 inches in a foot.
inches = miles * 5280 * 12;
Console.WriteLine("Distance to the sun: " +
inches + " inches.");
}
PROGRAM 24: (Even or Odd Locator )
static void Main(string[] args)
{
int a;
Console.WriteLine("Give a no: to find that either it is even or odd");
a = int.Parse(Console.ReadLine());
if (a % 2 == 0)
Console.WriteLine(a + "no is even");
else
Console.WriteLine(a + "no:is odd");
}
PROGRAM 25: (Prime Number )
static void Main(string[] args)
{
int a;
Console.WriteLine("Give a no: to find either it is prime or not");
a = int.Parse(Console.ReadLine());
if (a % 2 == 1)
Console.WriteLine("no: is prime");
else
Console.WriteLine("no: is not prime");
}
Programs Are Compiled By: Yasir Ahmed Khan | yasirahmedkhan@ymail.com | 03337015014
PROGRAM 26: (Discount Program)
static void Main(string[] args)
{
int price,quantity;
double discount;
double amounttobepaid;
Console.WriteLine("enter the price of the shoes");
price=int.Parse(Console.ReadLine());
Console.WriteLine("enter the quantity of pair of the shoes");
quantity = int.Parse(Console.ReadLine());
Console.WriteLine("enter the discount percentage");
discount = int.Parse(Console.ReadLine());
amounttobepaid = price - ((discount/100*price))*quantity;
Console.WriteLine("the price of shoes after deduction of discount is" + amounttobepaid);
}
PROGRAM 27: (square of a number using method)
static void Main(string[] args)
{
square(5);
}
public static void square(int a)
{
Console.WriteLine( a*a);
}
PROGRAM 28: (Even Number Series using method)
static void Main(string[] args)
{
evennumber(2, 20); // Starts From 2 , Ends at 20
}
public static void evennumber(int a,int b)
{
for (int x = a; x <= b; x= x+ 2)
Console.Write(x + ",");
}
PROGRAM 29: (QUEST NAWABSHAH)
static void Main(string[] args)
{
char [] quest = {'Q','U','E','S','T','N','A','W','A','B','S','H','A','H'};
for (int a = 0; a < 13; a++)
Console.Write(quest[a]);
}
Programs Are Compiled By: Yasir Ahmed Khan | yasirahmedkhan@ymail.com | 03337015014
PROGRAM 30: (Pakistan)
static void Main(string[] args)
{
char[] quest = { 'P', 'a', 'k', 'i', 's', 't', 'a', 'n'};
for (int a = 0; a < 7; a++)
Console.Write(quest[a]);
}
PROGRAM 31: (1/1, 2/3, 3/5. 4/7. 5/9, 6/11, 7/13, 8/15, 9/17)
static void Main(string[] args)
{
// 1/1, 2/3, 3/5. 4/7. 5/9, 6/11, 7/13, 8/15, 9/17
int a = 1, b = 1;
do
{
Console.Write(" "+a + "/" + b);
a++; b= b+ 2;
}
while (a < 10 && b < 18);
}
PROGRAM 32: (Swapping of Number)
int a, b;
Console.Write("Enter Number For a");
a = Int32.Parse(Console.ReadLine());
Console.Write("Enter Number For b");
b = Int32.Parse(Console.ReadLine());
Console.Write("Value of A before Swaping" + a);
Console.Write("nValue of B before Swaping" + b);
b = (a + b) - (a = b);
Console.Write("nnValue of A After Swaping" + a);
Console.Write("nValue of B After Swaping" + b);
PROGRAM 33: (Leap year)
static void Main(string[] args)
{
int year;
Console.Write("Enter a year to check if it is a leap year");
year = Int32.Parse(Console.ReadLine());
if (year % 400 == 0)
Console.Write(year + "is a leap Year");
else if (year % 100 == 0)
Console.Write(year + "is not a leap Year");
else if (year % 4 == 0)
Console.Write(year + "is a leap Year");
else
Console.Write(year + "is not a leap Year");
}
PROGRAM 34: (Factorial)
int a,n,fact=1;
Console.Write("Enter A Number to Calculate its Factorial ");
n=Int32.Parse(Console.ReadLine());
for (a = 1; a <= n; a++)
fact = fact * a;
Console.WriteLine("Factorial of " + n + " is " + fact);

More Related Content

What's hot

c++ program for Railway reservation
c++ program for Railway reservationc++ program for Railway reservation
c++ program for Railway reservationSwarup Kumar Boro
 
Mpesa_C# (2)
Mpesa_C# (2)Mpesa_C# (2)
Mpesa_C# (2)Soud Fosi
 
C++ Windows Forms L11 - Inheritance
C++ Windows Forms L11 - Inheritance C++ Windows Forms L11 - Inheritance
C++ Windows Forms L11 - Inheritance Mohammad Shaker
 
Emerging Languages: A Tour of the Horizon
Emerging Languages: A Tour of the HorizonEmerging Languages: A Tour of the Horizon
Emerging Languages: A Tour of the HorizonAlex Payne
 
Computer Science investigatory project class 12
Computer Science investigatory project class 12Computer Science investigatory project class 12
Computer Science investigatory project class 12Raunak Yadav
 
Complex Event Processor 3.0.0 - An overview of upcoming features
Complex Event Processor 3.0.0 - An overview of upcoming features Complex Event Processor 3.0.0 - An overview of upcoming features
Complex Event Processor 3.0.0 - An overview of upcoming features WSO2
 
C++ Windows Forms L10 - Instantiate
C++ Windows Forms L10 - InstantiateC++ Windows Forms L10 - Instantiate
C++ Windows Forms L10 - InstantiateMohammad Shaker
 
C++ Windows Forms L09 - GDI P2
C++ Windows Forms L09 - GDI P2C++ Windows Forms L09 - GDI P2
C++ Windows Forms L09 - GDI P2Mohammad Shaker
 
C++ Windows Forms L03 - Controls P2
C++ Windows Forms L03 - Controls P2C++ Windows Forms L03 - Controls P2
C++ Windows Forms L03 - Controls P2Mohammad Shaker
 

What's hot (13)

c++ program for Railway reservation
c++ program for Railway reservationc++ program for Railway reservation
c++ program for Railway reservation
 
Mpesa_C# (2)
Mpesa_C# (2)Mpesa_C# (2)
Mpesa_C# (2)
 
C++ Windows Forms L11 - Inheritance
C++ Windows Forms L11 - Inheritance C++ Windows Forms L11 - Inheritance
C++ Windows Forms L11 - Inheritance
 
PART 5: RASTER DATA
PART 5: RASTER DATAPART 5: RASTER DATA
PART 5: RASTER DATA
 
Arctic15 keynote
Arctic15   keynoteArctic15   keynote
Arctic15 keynote
 
Emerging Languages: A Tour of the Horizon
Emerging Languages: A Tour of the HorizonEmerging Languages: A Tour of the Horizon
Emerging Languages: A Tour of the Horizon
 
Computer Science investigatory project class 12
Computer Science investigatory project class 12Computer Science investigatory project class 12
Computer Science investigatory project class 12
 
Oop presentation
Oop presentationOop presentation
Oop presentation
 
Cpp programs
Cpp programsCpp programs
Cpp programs
 
Complex Event Processor 3.0.0 - An overview of upcoming features
Complex Event Processor 3.0.0 - An overview of upcoming features Complex Event Processor 3.0.0 - An overview of upcoming features
Complex Event Processor 3.0.0 - An overview of upcoming features
 
C++ Windows Forms L10 - Instantiate
C++ Windows Forms L10 - InstantiateC++ Windows Forms L10 - Instantiate
C++ Windows Forms L10 - Instantiate
 
C++ Windows Forms L09 - GDI P2
C++ Windows Forms L09 - GDI P2C++ Windows Forms L09 - GDI P2
C++ Windows Forms L09 - GDI P2
 
C++ Windows Forms L03 - Controls P2
C++ Windows Forms L03 - Controls P2C++ Windows Forms L03 - Controls P2
C++ Windows Forms L03 - Controls P2
 

Similar to Console programms

Similar to Console programms (20)

C# console programms
C# console programmsC# console programms
C# console programms
 
C#.net
C#.netC#.net
C#.net
 
Hems
HemsHems
Hems
 
.net progrmming part2
.net progrmming part2.net progrmming part2
.net progrmming part2
 
C# Lab Programs.pdf
C# Lab Programs.pdfC# Lab Programs.pdf
C# Lab Programs.pdf
 
C# Lab Programs.pdf
C# Lab Programs.pdfC# Lab Programs.pdf
C# Lab Programs.pdf
 
12th CBSE Practical File
12th CBSE Practical File12th CBSE Practical File
12th CBSE Practical File
 
Net practicals lab mannual
Net practicals lab mannualNet practicals lab mannual
Net practicals lab mannual
 
C Programming
C ProgrammingC Programming
C Programming
 
39927902 c-labmanual
39927902 c-labmanual39927902 c-labmanual
39927902 c-labmanual
 
39927902 c-labmanual
39927902 c-labmanual39927902 c-labmanual
39927902 c-labmanual
 
54602399 c-examples-51-to-108-programe-ee01083101
54602399 c-examples-51-to-108-programe-ee0108310154602399 c-examples-51-to-108-programe-ee01083101
54602399 c-examples-51-to-108-programe-ee01083101
 
C# console applications.docx
C# console applications.docxC# console applications.docx
C# console applications.docx
 
C lab
C labC lab
C lab
 
Loops (1)
Loops (1)Loops (1)
Loops (1)
 
Practical basics on c++
Practical basics on c++Practical basics on c++
Practical basics on c++
 
ASP.NET
ASP.NETASP.NET
ASP.NET
 
(ThoughtWorks Away Day 2009) one or two things you may not know about typesys...
(ThoughtWorks Away Day 2009) one or two things you may not know about typesys...(ThoughtWorks Away Day 2009) one or two things you may not know about typesys...
(ThoughtWorks Away Day 2009) one or two things you may not know about typesys...
 
.net progrmming part1
.net progrmming part1.net progrmming part1
.net progrmming part1
 
Mouse programming in c
Mouse programming in cMouse programming in c
Mouse programming in c
 

More from Yasir Khan (20)

Lecture 6
Lecture 6Lecture 6
Lecture 6
 
Lecture 4
Lecture 4Lecture 4
Lecture 4
 
Lecture 3
Lecture 3Lecture 3
Lecture 3
 
Lecture 2
Lecture 2Lecture 2
Lecture 2
 
Lec#1
Lec#1Lec#1
Lec#1
 
Ch10 (1)
Ch10 (1)Ch10 (1)
Ch10 (1)
 
Ch09
Ch09Ch09
Ch09
 
Ch05
Ch05Ch05
Ch05
 
Snooping protocols 3
Snooping protocols 3Snooping protocols 3
Snooping protocols 3
 
Snooping 2
Snooping 2Snooping 2
Snooping 2
 
Introduction 1
Introduction 1Introduction 1
Introduction 1
 
Hpc sys
Hpc sysHpc sys
Hpc sys
 
Hpc 6 7
Hpc 6 7Hpc 6 7
Hpc 6 7
 
Hpc 4 5
Hpc 4 5Hpc 4 5
Hpc 4 5
 
Hpc 3
Hpc 3Hpc 3
Hpc 3
 
Hpc 2
Hpc 2Hpc 2
Hpc 2
 
Hpc 1
Hpc 1Hpc 1
Hpc 1
 
Flynns classification
Flynns classificationFlynns classification
Flynns classification
 
Dir based imp_5
Dir based imp_5Dir based imp_5
Dir based imp_5
 
Natural Language Processing
Natural Language ProcessingNatural Language Processing
Natural Language Processing
 

Recently uploaded

batwheels_01batwheels_01batwheels_01batwheels_01
batwheels_01batwheels_01batwheels_01batwheels_01batwheels_01batwheels_01batwheels_01batwheels_01
batwheels_01batwheels_01batwheels_01batwheels_01Patricia Pham
 
一比一原版(Westminster毕业证)威斯敏斯特大学毕业证成绩单
一比一原版(Westminster毕业证)威斯敏斯特大学毕业证成绩单一比一原版(Westminster毕业证)威斯敏斯特大学毕业证成绩单
一比一原版(Westminster毕业证)威斯敏斯特大学毕业证成绩单utykdaq
 
Top Best IPTV Providers in the UK for 2024.pdf
Top Best IPTV Providers in the UK for 2024.pdfTop Best IPTV Providers in the UK for 2024.pdf
Top Best IPTV Providers in the UK for 2024.pdfXtreame HDTV
 
Water manjdjagement in problem soil.pptx
Water manjdjagement in problem soil.pptxWater manjdjagement in problem soil.pptx
Water manjdjagement in problem soil.pptxFaizanAhmad697379
 
A KING’S HEART THE STORY OF TSAR BORIS III (Drama) (Feature Film Project in D...
A KING’S HEART THE STORY OF TSAR BORIS III (Drama) (Feature Film Project in D...A KING’S HEART THE STORY OF TSAR BORIS III (Drama) (Feature Film Project in D...
A KING’S HEART THE STORY OF TSAR BORIS III (Drama) (Feature Film Project in D...Art Feeling Films
 
Bromazolam CAS 71368-80-4 high quality opiates, Safe transportation, 99% pure
Bromazolam CAS 71368-80-4 high quality opiates, Safe transportation, 99% pureBromazolam CAS 71368-80-4 high quality opiates, Safe transportation, 99% pure
Bromazolam CAS 71368-80-4 high quality opiates, Safe transportation, 99% pureamy56318795
 
Q4 WEEK 1 JUDGE THE RELEVANCE AND WORTH OF IDEAS.pptx
Q4 WEEK 1 JUDGE THE RELEVANCE AND WORTH OF IDEAS.pptxQ4 WEEK 1 JUDGE THE RELEVANCE AND WORTH OF IDEAS.pptx
Q4 WEEK 1 JUDGE THE RELEVANCE AND WORTH OF IDEAS.pptxramprakash8457
 
Vector Methods.pptxjjjjjjjjjjjjjjjjjjjjjj
Vector Methods.pptxjjjjjjjjjjjjjjjjjjjjjjVector Methods.pptxjjjjjjjjjjjjjjjjjjjjjj
Vector Methods.pptxjjjjjjjjjjjjjjjjjjjjjjjoshuaclack73
 
一比一原版(OSU毕业证)俄亥俄州立大学哥伦布分校毕业证成绩单
一比一原版(OSU毕业证)俄亥俄州立大学哥伦布分校毕业证成绩单一比一原版(OSU毕业证)俄亥俄州立大学哥伦布分校毕业证成绩单
一比一原版(OSU毕业证)俄亥俄州立大学哥伦布分校毕业证成绩单utykdaq
 
plantillas-powerpoint-hello-kitty.pptx.n
plantillas-powerpoint-hello-kitty.pptx.nplantillas-powerpoint-hello-kitty.pptx.n
plantillas-powerpoint-hello-kitty.pptx.nMayu Eliz
 
"My Silence, My Grave: The Making Of" Booklet
"My Silence, My Grave: The Making Of" Booklet"My Silence, My Grave: The Making Of" Booklet
"My Silence, My Grave: The Making Of" BookletDontLarry
 
Driving & Racing Games Online for Free_ Explore the Excitement with ATM HTML ...
Driving & Racing Games Online for Free_ Explore the Excitement with ATM HTML ...Driving & Racing Games Online for Free_ Explore the Excitement with ATM HTML ...
Driving & Racing Games Online for Free_ Explore the Excitement with ATM HTML ...ATM HTML Games
 
Get the Best Online Lotus ID from the Top Betting ID Provider.
Get the Best Online Lotus ID from the Top Betting ID Provider.Get the Best Online Lotus ID from the Top Betting ID Provider.
Get the Best Online Lotus ID from the Top Betting ID Provider.virat777exch786
 
一比一原版(UCL毕业证)伦敦大学学院毕业证成绩单
一比一原版(UCL毕业证)伦敦大学学院毕业证成绩单一比一原版(UCL毕业证)伦敦大学学院毕业证成绩单
一比一原版(UCL毕业证)伦敦大学学院毕业证成绩单utykdaq
 
一比一原版(SDSU毕业证)圣地亚哥州立大学毕业证成绩单
一比一原版(SDSU毕业证)圣地亚哥州立大学毕业证成绩单一比一原版(SDSU毕业证)圣地亚哥州立大学毕业证成绩单
一比一原版(SDSU毕业证)圣地亚哥州立大学毕业证成绩单utykdaq
 
Pushpa 2 Release Date not Postponed According to the Makers.pdf
Pushpa 2 Release Date not Postponed According to the Makers.pdfPushpa 2 Release Date not Postponed According to the Makers.pdf
Pushpa 2 Release Date not Postponed According to the Makers.pdfkigaya33
 
一比一原版(UAL毕业证)伦敦艺术大学毕业证成绩单
一比一原版(UAL毕业证)伦敦艺术大学毕业证成绩单一比一原版(UAL毕业证)伦敦艺术大学毕业证成绩单
一比一原版(UAL毕业证)伦敦艺术大学毕业证成绩单utykdaq
 
PPT aviator (A small guide on spinmatch).pptx
PPT aviator (A small guide on spinmatch).pptxPPT aviator (A small guide on spinmatch).pptx
PPT aviator (A small guide on spinmatch).pptxspinmatch13
 

Recently uploaded (19)

batwheels_01batwheels_01batwheels_01batwheels_01
batwheels_01batwheels_01batwheels_01batwheels_01batwheels_01batwheels_01batwheels_01batwheels_01
batwheels_01batwheels_01batwheels_01batwheels_01
 
一比一原版(Westminster毕业证)威斯敏斯特大学毕业证成绩单
一比一原版(Westminster毕业证)威斯敏斯特大学毕业证成绩单一比一原版(Westminster毕业证)威斯敏斯特大学毕业证成绩单
一比一原版(Westminster毕业证)威斯敏斯特大学毕业证成绩单
 
Top Best IPTV Providers in the UK for 2024.pdf
Top Best IPTV Providers in the UK for 2024.pdfTop Best IPTV Providers in the UK for 2024.pdf
Top Best IPTV Providers in the UK for 2024.pdf
 
Water manjdjagement in problem soil.pptx
Water manjdjagement in problem soil.pptxWater manjdjagement in problem soil.pptx
Water manjdjagement in problem soil.pptx
 
A KING’S HEART THE STORY OF TSAR BORIS III (Drama) (Feature Film Project in D...
A KING’S HEART THE STORY OF TSAR BORIS III (Drama) (Feature Film Project in D...A KING’S HEART THE STORY OF TSAR BORIS III (Drama) (Feature Film Project in D...
A KING’S HEART THE STORY OF TSAR BORIS III (Drama) (Feature Film Project in D...
 
Bromazolam CAS 71368-80-4 high quality opiates, Safe transportation, 99% pure
Bromazolam CAS 71368-80-4 high quality opiates, Safe transportation, 99% pureBromazolam CAS 71368-80-4 high quality opiates, Safe transportation, 99% pure
Bromazolam CAS 71368-80-4 high quality opiates, Safe transportation, 99% pure
 
Q4 WEEK 1 JUDGE THE RELEVANCE AND WORTH OF IDEAS.pptx
Q4 WEEK 1 JUDGE THE RELEVANCE AND WORTH OF IDEAS.pptxQ4 WEEK 1 JUDGE THE RELEVANCE AND WORTH OF IDEAS.pptx
Q4 WEEK 1 JUDGE THE RELEVANCE AND WORTH OF IDEAS.pptx
 
Vector Methods.pptxjjjjjjjjjjjjjjjjjjjjjj
Vector Methods.pptxjjjjjjjjjjjjjjjjjjjjjjVector Methods.pptxjjjjjjjjjjjjjjjjjjjjjj
Vector Methods.pptxjjjjjjjjjjjjjjjjjjjjjj
 
一比一原版(OSU毕业证)俄亥俄州立大学哥伦布分校毕业证成绩单
一比一原版(OSU毕业证)俄亥俄州立大学哥伦布分校毕业证成绩单一比一原版(OSU毕业证)俄亥俄州立大学哥伦布分校毕业证成绩单
一比一原版(OSU毕业证)俄亥俄州立大学哥伦布分校毕业证成绩单
 
plantillas-powerpoint-hello-kitty.pptx.n
plantillas-powerpoint-hello-kitty.pptx.nplantillas-powerpoint-hello-kitty.pptx.n
plantillas-powerpoint-hello-kitty.pptx.n
 
"My Silence, My Grave: The Making Of" Booklet
"My Silence, My Grave: The Making Of" Booklet"My Silence, My Grave: The Making Of" Booklet
"My Silence, My Grave: The Making Of" Booklet
 
Driving & Racing Games Online for Free_ Explore the Excitement with ATM HTML ...
Driving & Racing Games Online for Free_ Explore the Excitement with ATM HTML ...Driving & Racing Games Online for Free_ Explore the Excitement with ATM HTML ...
Driving & Racing Games Online for Free_ Explore the Excitement with ATM HTML ...
 
kiff2
kiff2kiff2
kiff2
 
Get the Best Online Lotus ID from the Top Betting ID Provider.
Get the Best Online Lotus ID from the Top Betting ID Provider.Get the Best Online Lotus ID from the Top Betting ID Provider.
Get the Best Online Lotus ID from the Top Betting ID Provider.
 
一比一原版(UCL毕业证)伦敦大学学院毕业证成绩单
一比一原版(UCL毕业证)伦敦大学学院毕业证成绩单一比一原版(UCL毕业证)伦敦大学学院毕业证成绩单
一比一原版(UCL毕业证)伦敦大学学院毕业证成绩单
 
一比一原版(SDSU毕业证)圣地亚哥州立大学毕业证成绩单
一比一原版(SDSU毕业证)圣地亚哥州立大学毕业证成绩单一比一原版(SDSU毕业证)圣地亚哥州立大学毕业证成绩单
一比一原版(SDSU毕业证)圣地亚哥州立大学毕业证成绩单
 
Pushpa 2 Release Date not Postponed According to the Makers.pdf
Pushpa 2 Release Date not Postponed According to the Makers.pdfPushpa 2 Release Date not Postponed According to the Makers.pdf
Pushpa 2 Release Date not Postponed According to the Makers.pdf
 
一比一原版(UAL毕业证)伦敦艺术大学毕业证成绩单
一比一原版(UAL毕业证)伦敦艺术大学毕业证成绩单一比一原版(UAL毕业证)伦敦艺术大学毕业证成绩单
一比一原版(UAL毕业证)伦敦艺术大学毕业证成绩单
 
PPT aviator (A small guide on spinmatch).pptx
PPT aviator (A small guide on spinmatch).pptxPPT aviator (A small guide on spinmatch).pptx
PPT aviator (A small guide on spinmatch).pptx
 

Console programms

  • 1. Programs Are Compiled By: Yasir Ahmed Khan | yasirahmedkhan@ymail.com | 03337015014 CONSOLE PROGRAMSCONSOLE PROGRAMSCONSOLE PROGRAMSCONSOLE PROGRAMS By: Yasir A k PROGRAM 01: (Print Name) static void Main(string[] args) { Console.WriteLine("Welcome"); //Console is a built-in class that contains the methods for displaying messages on the // screen and getting input from the keyboard. string name; Console.Write("Enter Your Name: "); name = Console.ReadLine(); // Input Console.WriteLine("Your Name Is: " + name); Console.ReadKey(); // to hold output like getch() } PROGRAM 02: (Print Integer) static void Main(string[] args) { int myInteger; string myString; myInteger = 17; myString = ""My Integer" is"; Console.WriteLine(myString +" "+ myInteger); Console.ReadKey(); } PROGRAM 03: (Addition, Subtraction, Multiplication and Division of a Number) static void Main(string[] args) { double firstNumber, secondNumber; string userName; Console.WriteLine("Enter your Name: "); userName = Console.ReadLine(); Console.WriteLine("Welcome "+ userName); Console.WriteLine("Now give me a number:"); firstNumber = Convert.ToDouble(Console.ReadLine()); Console.WriteLine("Now give me another number:"); secondNumber = Convert.ToDouble(Console.ReadLine()); Console.WriteLine("The sum of {0} and {1} is {2}.", firstNumber, secondNumber, firstNumber + secondNumber); Console.WriteLine("The result of subtracting {0} from {1} is {2}.", secondNumber, firstNumber, firstNumber - secondNumber); Console.WriteLine("The product of {0} and {1} is {2}.", firstNumber, secondNumber, firstNumber * secondNumber); Console.WriteLine("The result of dividing {0} by {1} is {2}.", firstNumber, secondNumber, firstNumber / secondNumber); Console.WriteLine("The remainder after dividing {0} by {1} is {2}.", firstNumber, secondNumber, firstNumber % secondNumber); Console.ReadKey(); }
  • 2. Programs Are Compiled By: Yasir Ahmed Khan | yasirahmedkhan@ymail.com | 03337015014 PROGRAM 04: (Marks Sheet) static void Main(string[] args) { int phy, maths,eng,cp,isl; int total; double per; Console.WriteLine("nttt MARKS CERTIFICATE "); Console.Write("nEnter Physics Marks:"); phy = Convert.ToInt32(Console.ReadLine()); Console.Write("nEnter Mathematics Marks:"); maths = Convert.ToInt32(Console.ReadLine()); Console.Write("nEnter English Marks: "); eng = Convert.ToInt32(Console.ReadLine()); Console.Write("nEnter Programming Marks:"); cp = Convert.ToInt32(Console.ReadLine()); Console.Write("nEnter Islamiat Marks:"); isl = Convert.ToInt32(Console.ReadLine()); total = phy + maths+ isl + cp +eng; per = (total * 100) / 550; Console.WriteLine("Total is: "+Convert.ToInt32(total)); Console.WriteLine("Percentage is: {0} %" , Convert.ToDouble(per)); Console.WriteLine("n"); if (per > 80.0) Console.WriteLine("You Got Grade: A1 "); else if (per > 70.0) Console.WriteLine("You Got Grade: A"); else if (per > 60.0) Console.WriteLine("You Got Grade: B"); else if (per > 50.0) Console.WriteLine("You Got Grade: C"); else if (per < 49.9) Console.WriteLine("Your Fail"); Console.WriteLine("nnttThis Software is Developed By: Yasir Ahmed Khan"); Console.ReadKey(); } PROGRAM 05: Table using For Loop static void Main(string[] args) { int tab_no; Console.WriteLine("ntttTable Generatorn"); Console.Write("Enter Table No: "); tab_no = Convert.ToInt32(Console.ReadLine()); for(int x=1; x<=10;x++) { Console.WriteLine("n{0} * {1} = {2}",tab_no,x,(tab_no*x) ); } Console.ReadKey(); }
  • 3. Programs Are Compiled By: Yasir Ahmed Khan | yasirahmedkhan@ymail.com | 03337015014 PROGRAM 06: Sum of Two Number’s { int number1, number2, sum; Console.Write("Enter First No:"); number1 = Convert.ToInt32(Console.ReadLine()); Console.Write("Enter Second No:"); number2 = Convert.ToInt32(Console.ReadLine()); sum = number1 + number2; Console.Write("Sum is " + sum); Console.WriteLine("nnttt This Program is Written By: Yasir Ahmed Khan"); Console.ReadKey(); } PROGRAM 07: Cities Temperature { double nshah, khi, hyd, multan, isd, lahore, average; Console.WriteLine("nnttt AVERAGE TEMPERATURE"); Console.Write("nEnter Temperature of Nawabshah City :"); nshah = Convert.ToDouble(Console.ReadLine()); Console.Write("nEnter Temperature of Hyderabad City :"); hyd = Convert.ToDouble(Console.ReadLine()); Console.Write("nEnter Temperature of Multan City :"); multan = Convert.ToDouble(Console.ReadLine()); Console.Write("nEnter Temperature of Islamabad City :"); isd = Convert.ToDouble(Console.ReadLine()); Console.Write("nEnter Temperature of Lahore City :"); lahore = Convert.ToDouble(Console.ReadLine()); Console.Write("nEnter Temperature of Karachi City :"); khi = Convert.ToDouble(Console.ReadLine()); average = (nshah + hyd + multan + isd + lahore) / 6; Console.WriteLine("nnAVERAGE TEMPERATURE IS: " + average); Console.WriteLine("nnttt This Program is Written By: Yasir Ahmed Khan"); Console.ReadKey(); } PROGRAM 08: Square & Cube of a Number { int num,square,cube,sq_root; Console.Write("Enter Number: "); num = Convert.ToInt32(Console.ReadLine()); square = num * num; cube = square * num; Console.WriteLine("nn Square is " + square); Console.WriteLine("nn Cube is " + cube); Console.WriteLine("nnttt This Program is Written By: Yasir Ahmed Khan"); Console.ReadKey(); }
  • 4. Programs Are Compiled By: Yasir Ahmed Khan | yasirahmedkhan@ymail.com | 03337015014 PROGRAM 09: Number Compression { int num1, num2; Console.Write("nntt COMPARISSION B/W TWO NUMBER's"); Console.Write("nnEnter Ist Number "); num1 = Convert.ToInt32(Console.ReadLine()); Console.Write("Enter IInd Number "); num2 = Convert.ToInt32(Console.ReadLine()); if (num1 == num2) Console.WriteLine(num1+" is Equals to "+num2); if(num1>num2) Console.WriteLine(num1 + " is Greater Than " + num2); if (num1 < num2) Console.WriteLine(num1 + " is Less Than " + num2); if (num1 != num2) Console.WriteLine(num1 + " is Not Equals to " + num2); if (num1 >= num2) Console.WriteLine(num1 + " is Greater Than or equals to " + num2); if (num1 <= num2) Console.WriteLine(num1 + " is Less Than or equals to " + num2); Console.WriteLine("nnttt This Program is Written By: Yasir Ahmed Khan"); Console.ReadKey(); } PROGRAM 10: Kilo Meter to meter { int meter, km; Console.Write("nntt Enter Value in Kilo Meter "); km = Convert.ToInt32(Console.ReadLine()); meter = km * 1000 ; Console.Write("nntt The Value in Meter Is " + meter); Console.WriteLine("nnttt This Program is Written By: Yasir Ahmed Khan"); Console.ReadKey(); }
  • 5. Programs Are Compiled By: Yasir Ahmed Khan | yasirahmedkhan@ymail.com | 03337015014 PROGRAM 11: Age Analyzer { int year, month,day; Console.Write("nntt Enter The Age in Year "); year = Convert.ToInt32(Console.ReadLine()); Console.Write("nntt Enter The Age in MOnth "); month = Convert.ToInt32(Console.ReadLine()); day = year * 365 + month *30 ; Console.Write("nntt Your " + day + " days old"); Console.WriteLine("nnttt This Program is Written By: Yasir Ahmed Khan"); Console.ReadKey(); } PROGRAM 12: KB to Byte Conversion { int bit,kb; Console.Write("nntt Enter The Data Size in Kilo Bytes "); kb = Convert.ToInt32(Console.ReadLine()); bit = kb * 1024 ; Console.Write("nntt Your Data Size is " + bit + " Byte "); Console.WriteLine("nnttt This Program is Written By: Yasir Ahmed Khan"); Console.ReadKey(); } PROGRAM 13: Temperature Conversion static void Main(string[] args) { //Temperature of a city in Fahrenheit degrees is input through the keyboard. //Write a program to convert this temperature into Centigrade degrees. double temp_f, temp_c; Console.WriteLine("Enter Your City Temperature: "); temp_f = double.Parse(Console.ReadLine()); temp_c = (temp_f - 32) * 5 / 9; Console.WriteLine("Temperature in Celsius is : " + temp_c); Console.WriteLine("nnttt This Program is Written By: Yasir Ahmed Khan"); Console.ReadKey(); }
  • 6. Programs Are Compiled By: Yasir Ahmed Khan | yasirahmedkhan@ymail.com | 03337015014 PROGRAM 14: Conversion of Length static void Main(string[] args) { //The distance between two cities (in km.) is input through the keyboard. //Write a program to convert and print this distance in meters, feet, inches and centimeters. double km, m, feet, inches, centimeter; Console.Write("Enter Distance B/w Two Cities in Kilo Meter: "); km = double.Parse(Console.ReadLine()); m = km * 1000; feet = m * 3.28084; centimeter = m * 100; inches = m * 39.37008; Console.WriteLine("Distance in Km : " + km); Console.WriteLine("Distance in m : " + m); Console.WriteLine("Distance in feet : " + feet); Console.WriteLine("Distance in centimeter : " + centimeter); Console.WriteLine("Distance in inches : " + inches); Console.WriteLine("nnttt This Program is Written By: Yasir Ahmed Khan"); Console.ReadKey(); } PROGRAM 15: Salary Sheet static void Main(string[] args) { //Ramesh’s basic salary is input through the keyboard. //His dearness allowance is 40% of basic salary, and house rent allowance is 20% of basic salary. //Write a program to calculate his gross salary. int basic_salary; double dearnesss_allowance, house_rent_allowance, gross_salary; Console.Write("nn ttPlease Enter Your Basic Salary: "); basic_salary = int.Parse(Console.ReadLine()); dearnesss_allowance = (basic_salary * 0.4); house_rent_allowance= (basic_salary * 0.2); gross_salary = dearnesss_allowance + house_rent_allowance + basic_salary; Console.WriteLine("n ttBasic Salary: " + basic_salary); Console.WriteLine("n ttDearness Allowance: " + dearnesss_allowance); Console.WriteLine("n ttHouse Rent Allowance: " + house_rent_allowance); Console.WriteLine("n ttGross Salary: " + gross_salary); Console.WriteLine("nnttt This Program is Written By: Yasir Ahmed Khan"); Console.ReadKey(); }
  • 7. Programs Are Compiled By: Yasir Ahmed Khan | yasirahmedkhan@ymail.com | 03337015014 PROGRAM 16: Age Analyzer static void Main(string[] args) { int age, days, month; Console.WriteLine("give your age progarme will convert it into days"); Console.WriteLine("give your age in years"); age = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("give your age in months"); month = Convert.ToInt32(Console.ReadLine()); days = age * 365 + month * 30; Console.WriteLine("conversion successful,the days will be " + days + " in " + age + " year " + "and" + month+ "months"); } PROGRAM 17: Modulus / Absolute static void Main(string[] args) { // Finding Absoulute Value or Modulus int modulus_no; Console.WriteLine("Enter No Which u want to want to find out modulus"); modulus_no = int.Parse(Console.ReadLine()); Console.WriteLine(Math.Abs(modulus_no)); Console.ReadKey(); } PROGRAM 18: Largest Number { //Finding Greater Number B/w Three Number's int n1, n2, n3; Console.WriteLine("Enter 1st Number: "); n1 = int.Parse(Console.ReadLine()); Console.WriteLine("Enter 2nd Number: "); n2 = int.Parse(Console.ReadLine()); Console.WriteLine("Enter 3rd Number: "); n3 = int.Parse(Console.ReadLine()); if (n1 > n2 && n1 > n3) Console.WriteLine("n{0} is greater than {1} & {2}", n1, n2, n3); else if (n2 > n3 && n2 > n1) Console.WriteLine("n{0} is greater than {1} & {2}", n2, n1, n3); else if (n3 > n1 && n3 > n2) Console.WriteLine("n{0} is greater than {1} & {2}", n3, n2, n1); else Console.WriteLine("Number's Are Equals"); Console.ReadKey(); }
  • 8. Programs Are Compiled By: Yasir Ahmed Khan | yasirahmedkhan@ymail.com | 03337015014 PROGRAM 18: Book Shop { int choice,engchoice,pchoice,dchoice; Console.WriteLine("Welcome In Liberty Books Pvt Ltd. nnn Please Enter Which Subject Book You Want To Buy nnn1. English n2. Programming n3. Data Basen"); Console.WriteLine("Enter Choice B/w 1-3"); choice = Convert.ToInt32(Console.ReadLine()); if (choice == 1) { Console.WriteLine("Now , n Please Enter Which Book You Want To Buy nnn1. English By Michel John n2. English By Oxfor Printing Press n3. English Dictonary hn"); Console.WriteLine("Enter B/w 1-3"); engchoice = Convert.ToInt32(Console.ReadLine()); if (engchoice == 1) { Console.WriteLine("English By Michel John price is $ 45"); Console.ReadKey(); } if (engchoice == 2) { Console.WriteLine("English By Oxfor Printing Press price is $ 55"): Console.ReadKey(); } if(engchoice==3) { Console.WriteLine("English Dictonary Price is $ 10"); Console.ReadKey(); } else Console.WriteLine("Invalid Range"); Console.ReadKey(); } if(choice==2) { Console.WriteLine("Now , n Please Enter Which Book You Want To Buy nnn1. C Programming n2. C# Programming n3. Java n"); Console.WriteLine("Enter B/w 1-3"); pchoice = Convert.ToInt32(Console.ReadLine()); if (pchoice == 1) { Console.WriteLine("C Programming Book price is $ 45"); Console.ReadKey(); } if (pchoice == 2) { Console.WriteLine("C# Programming Book Press price is $ 55"); Console.ReadKey(); } if(pchoice==3) { Console.WriteLine("Java Programming Book Price is $ 10"); Console.ReadKey(); } else Console.WriteLine("Invalid Range"); } if (choice == 3) { Console.WriteLine("Now , n Please Enter Which Book You Want To Buy nnn1. Basic Data Base n2. Oracle 10g n3. My Bank DataBase n"); Console.WriteLine("Enter B/w 1-3"); dchoice = Convert.ToInt32(Console.ReadLine()); if (dchoice == 1) { Console.WriteLine("Basic Database Book price is $ 45"); Console.ReadKey(); } if (dchoice == 2) { Console.WriteLine("Oracle 10.G Book Press price is $ 55"); Console.ReadKey(); } if (dchoice == 3) { Console.WriteLine("My Bank Database Book Price is $ 10"); Console.ReadKey(); } else Console.WriteLine("Invalid Range");} else { Console.WriteLine("Invalid Range"); } Console.WriteLine("nn This Program is Write By: Yasir Ahmed Khan");
  • 9. Programs Are Compiled By: Yasir Ahmed Khan | yasirahmedkhan@ymail.com | 03337015014 } PROGRAM 19: Area Of Square { int width,height,area; Console.WriteLine("Enter Width:"); width = Int.Parse(Console.ReadLine()); Console.WriteLine("Enter Height:"); height = Int.Parse(Console.ReadLine()); area = width * height; Console.WriteLine("Area of Square is "+area); } PROGRAM 20: (Area Of Circumference) { double radius,area; Console.WriteLine("Enter Radius:"); radius = Double.Parse(Console.ReadLine()); area = radius * 3.14; Console.WriteLine("Area of circumference is "+area); } PROGRAM 21: (Alpha , Beta , Theta ) static void Main(string[] args) { Double theta; Console.WriteLine("give any angle to fint its value"); theta=Convert.ToInt32(Console.ReadLine()); { Console.WriteLine("Sine of " + theta + " is " + Math.Sin(theta)); Console.WriteLine("Cosine of " + theta + " is " + Math.Cos(theta)); Console.WriteLine("Tangent of " + theta + " is " + Math.Tan(theta)); Console.WriteLine(); } PROGRAM 22: (Table With Start and Ending Point ) static void Main(string[] args) { Console.WriteLine("give table no: which you want"); int a = int.Parse(Console.ReadLine()); Console.WriteLine("give starting point of table"); int b = int.Parse(Console.ReadLine()); Console.WriteLine("give ending point of table"); int c = int.Parse(Console.ReadLine()); for (int d = a; d <= c; d++) Console.WriteLine(a + "*" + d + "="+(a * d)) }
  • 10. Programs Are Compiled By: Yasir Ahmed Khan | yasirahmedkhan@ymail.com | 03337015014 PROGRAM 23: (Sun to Earth Distance ) static void Main(string[] args) { long inches; long miles; miles = 93000000; // 93,000,000 miles to the sun // 5,280 feet in a mile, 12 inches in a foot. inches = miles * 5280 * 12; Console.WriteLine("Distance to the sun: " + inches + " inches."); } PROGRAM 24: (Even or Odd Locator ) static void Main(string[] args) { int a; Console.WriteLine("Give a no: to find that either it is even or odd"); a = int.Parse(Console.ReadLine()); if (a % 2 == 0) Console.WriteLine(a + "no is even"); else Console.WriteLine(a + "no:is odd"); } PROGRAM 25: (Prime Number ) static void Main(string[] args) { int a; Console.WriteLine("Give a no: to find either it is prime or not"); a = int.Parse(Console.ReadLine()); if (a % 2 == 1) Console.WriteLine("no: is prime"); else Console.WriteLine("no: is not prime"); }
  • 11. Programs Are Compiled By: Yasir Ahmed Khan | yasirahmedkhan@ymail.com | 03337015014 PROGRAM 26: (Discount Program) static void Main(string[] args) { int price,quantity; double discount; double amounttobepaid; Console.WriteLine("enter the price of the shoes"); price=int.Parse(Console.ReadLine()); Console.WriteLine("enter the quantity of pair of the shoes"); quantity = int.Parse(Console.ReadLine()); Console.WriteLine("enter the discount percentage"); discount = int.Parse(Console.ReadLine()); amounttobepaid = price - ((discount/100*price))*quantity; Console.WriteLine("the price of shoes after deduction of discount is" + amounttobepaid); } PROGRAM 27: (square of a number using method) static void Main(string[] args) { square(5); } public static void square(int a) { Console.WriteLine( a*a); } PROGRAM 28: (Even Number Series using method) static void Main(string[] args) { evennumber(2, 20); // Starts From 2 , Ends at 20 } public static void evennumber(int a,int b) { for (int x = a; x <= b; x= x+ 2) Console.Write(x + ","); } PROGRAM 29: (QUEST NAWABSHAH) static void Main(string[] args) { char [] quest = {'Q','U','E','S','T','N','A','W','A','B','S','H','A','H'}; for (int a = 0; a < 13; a++) Console.Write(quest[a]); }
  • 12. Programs Are Compiled By: Yasir Ahmed Khan | yasirahmedkhan@ymail.com | 03337015014 PROGRAM 30: (Pakistan) static void Main(string[] args) { char[] quest = { 'P', 'a', 'k', 'i', 's', 't', 'a', 'n'}; for (int a = 0; a < 7; a++) Console.Write(quest[a]); } PROGRAM 31: (1/1, 2/3, 3/5. 4/7. 5/9, 6/11, 7/13, 8/15, 9/17) static void Main(string[] args) { // 1/1, 2/3, 3/5. 4/7. 5/9, 6/11, 7/13, 8/15, 9/17 int a = 1, b = 1; do { Console.Write(" "+a + "/" + b); a++; b= b+ 2; } while (a < 10 && b < 18); } PROGRAM 32: (Swapping of Number) int a, b; Console.Write("Enter Number For a"); a = Int32.Parse(Console.ReadLine()); Console.Write("Enter Number For b"); b = Int32.Parse(Console.ReadLine()); Console.Write("Value of A before Swaping" + a); Console.Write("nValue of B before Swaping" + b); b = (a + b) - (a = b); Console.Write("nnValue of A After Swaping" + a); Console.Write("nValue of B After Swaping" + b); PROGRAM 33: (Leap year) static void Main(string[] args) { int year; Console.Write("Enter a year to check if it is a leap year"); year = Int32.Parse(Console.ReadLine()); if (year % 400 == 0) Console.Write(year + "is a leap Year"); else if (year % 100 == 0) Console.Write(year + "is not a leap Year"); else if (year % 4 == 0) Console.Write(year + "is a leap Year"); else Console.Write(year + "is not a leap Year"); } PROGRAM 34: (Factorial) int a,n,fact=1; Console.Write("Enter A Number to Calculate its Factorial "); n=Int32.Parse(Console.ReadLine()); for (a = 1; a <= n; a++) fact = fact * a; Console.WriteLine("Factorial of " + n + " is " + fact);