SlideShare a Scribd company logo
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);
Ad

Recommended

Bookstore-Project
Bookstore-Project
Christopher Singleton
 
Swift Ready for Production?
Swift Ready for Production?
Crispy Mountain
 
Cs pritical file
Cs pritical file
Mitul Patel
 
Vb.net programs
Vb.net programs
R. S. Mundle Dharampeth Arts & Commerce College
 
PART 6: FROM GEO INTO YOUR REPORT
PART 6: FROM GEO INTO YOUR REPORT
Andrea Antonello
 
Продвинутая отладка JavaScript с помощью Chrome Dev Tools
Продвинутая отладка JavaScript с помощью Chrome Dev Tools
FDConf
 
PART 3: THE SCRIPTING COMPOSER AND PYTHON
PART 3: THE SCRIPTING COMPOSER AND PYTHON
Andrea Antonello
 
PART 4: GEOGRAPHIC SCRIPTING
PART 4: GEOGRAPHIC SCRIPTING
Andrea Antonello
 
c++ program for Railway reservation
c++ program for Railway reservation
Swarup Kumar Boro
 
Mpesa_C# (2)
Mpesa_C# (2)
Soud Fosi
 
C++ Windows Forms L11 - Inheritance
C++ Windows Forms L11 - Inheritance
Mohammad Shaker
 
PART 5: RASTER DATA
PART 5: RASTER DATA
Andrea Antonello
 
Arctic15 keynote
Arctic15 keynote
Jerry Jalava
 
Emerging Languages: A Tour of the Horizon
Emerging Languages: A Tour of the Horizon
Alex Payne
 
Computer Science investigatory project class 12
Computer Science investigatory project class 12
Raunak Yadav
 
Oop presentation
Oop presentation
Ch shampi Ch shampi
 
Cpp programs
Cpp programs
harman kaur
 
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 - Instantiate
Mohammad Shaker
 
C++ Windows Forms L09 - GDI P2
C++ Windows Forms L09 - GDI P2
Mohammad Shaker
 
C++ Windows Forms L03 - Controls P2
C++ Windows Forms L03 - Controls P2
Mohammad Shaker
 
C# console programms
C# console programms
Yasir Khan
 
C#.net
C#.net
vnboghani
 
Oops pramming with examples
Oops pramming with examples
Syed Khaleel
 
Chapter i c#(console application and programming)
Chapter i c#(console application and programming)
Chhom Karath
 
04 Console input output-
04 Console input output-
maznabili
 
Visula C# Programming Lecture 2
Visula C# Programming Lecture 2
Abou Bakr Ashraf
 
Lesson 1 INTRODUCTION TO C# LANGUAGE.pdf
Lesson 1 INTRODUCTION TO C# LANGUAGE.pdf
John Burca
 
04. Console Input Output
04. Console Input Output
Intro C# Book
 
C# console applications.docx
C# console applications.docx
MehwishKanwal14
 

More Related Content

What's hot (13)

c++ program for Railway reservation
c++ program for Railway reservation
Swarup Kumar Boro
 
Mpesa_C# (2)
Mpesa_C# (2)
Soud Fosi
 
C++ Windows Forms L11 - Inheritance
C++ Windows Forms L11 - Inheritance
Mohammad Shaker
 
PART 5: RASTER DATA
PART 5: RASTER DATA
Andrea Antonello
 
Arctic15 keynote
Arctic15 keynote
Jerry Jalava
 
Emerging Languages: A Tour of the Horizon
Emerging Languages: A Tour of the Horizon
Alex Payne
 
Computer Science investigatory project class 12
Computer Science investigatory project class 12
Raunak Yadav
 
Oop presentation
Oop presentation
Ch shampi Ch shampi
 
Cpp programs
Cpp programs
harman kaur
 
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 - Instantiate
Mohammad Shaker
 
C++ Windows Forms L09 - GDI P2
C++ Windows Forms L09 - GDI P2
Mohammad Shaker
 
C++ Windows Forms L03 - Controls P2
C++ Windows Forms L03 - Controls P2
Mohammad Shaker
 
c++ program for Railway reservation
c++ program for Railway reservation
Swarup Kumar Boro
 
Mpesa_C# (2)
Mpesa_C# (2)
Soud Fosi
 
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 Horizon
Alex Payne
 
Computer Science investigatory project class 12
Computer Science investigatory project class 12
Raunak Yadav
 
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 - Instantiate
Mohammad Shaker
 
C++ Windows Forms L09 - GDI P2
C++ Windows Forms L09 - GDI P2
Mohammad Shaker
 
C++ Windows Forms L03 - Controls P2
C++ Windows Forms L03 - Controls P2
Mohammad Shaker
 

Similar to Console programms (20)

C# console programms
C# console programms
Yasir Khan
 
C#.net
C#.net
vnboghani
 
Oops pramming with examples
Oops pramming with examples
Syed Khaleel
 
Chapter i c#(console application and programming)
Chapter i c#(console application and programming)
Chhom Karath
 
04 Console input output-
04 Console input output-
maznabili
 
Visula C# Programming Lecture 2
Visula C# Programming Lecture 2
Abou Bakr Ashraf
 
Lesson 1 INTRODUCTION TO C# LANGUAGE.pdf
Lesson 1 INTRODUCTION TO C# LANGUAGE.pdf
John Burca
 
04. Console Input Output
04. Console Input Output
Intro C# Book
 
C# console applications.docx
C# console applications.docx
MehwishKanwal14
 
Advanced Computer Programming..pptx
Advanced Computer Programming..pptx
KrishanthaRanaweera1
 
Introduction to c first week slides
Introduction to c first week slides
luqman bawany
 
Csphtp1 05
Csphtp1 05
HUST
 
C# slid
C# slid
pacatarpit
 
Lesson 4 Basic Programming Constructs.pptx
Lesson 4 Basic Programming Constructs.pptx
John Burca
 
SPF Getting Started - Console Program
SPF Getting Started - Console Program
Hock Leng PUAH
 
Getting Started - Console Program and Problem Solving
Getting Started - Console Program and Problem Solving
Hock Leng PUAH
 
Loops (1)
Loops (1)
esmail said
 
RandomGuessingGame
RandomGuessingGame
Christopher Singleton
 
Flow Control and Exception Handling.pptx
Flow Control and Exception Handling.pptx
Sheetal343198
 
For Beginners - C#
For Beginners - C#
Snehal Harawande
 
C# console programms
C# console programms
Yasir Khan
 
Oops pramming with examples
Oops pramming with examples
Syed Khaleel
 
Chapter i c#(console application and programming)
Chapter i c#(console application and programming)
Chhom Karath
 
04 Console input output-
04 Console input output-
maznabili
 
Visula C# Programming Lecture 2
Visula C# Programming Lecture 2
Abou Bakr Ashraf
 
Lesson 1 INTRODUCTION TO C# LANGUAGE.pdf
Lesson 1 INTRODUCTION TO C# LANGUAGE.pdf
John Burca
 
04. Console Input Output
04. Console Input Output
Intro C# Book
 
C# console applications.docx
C# console applications.docx
MehwishKanwal14
 
Advanced Computer Programming..pptx
Advanced Computer Programming..pptx
KrishanthaRanaweera1
 
Introduction to c first week slides
Introduction to c first week slides
luqman bawany
 
Csphtp1 05
Csphtp1 05
HUST
 
Lesson 4 Basic Programming Constructs.pptx
Lesson 4 Basic Programming Constructs.pptx
John Burca
 
SPF Getting Started - Console Program
SPF Getting Started - Console Program
Hock Leng PUAH
 
Getting Started - Console Program and Problem Solving
Getting Started - Console Program and Problem Solving
Hock Leng PUAH
 
Flow Control and Exception Handling.pptx
Flow Control and Exception Handling.pptx
Sheetal343198
 
Ad

More from Yasir Khan (20)

Lecture 6
Lecture 6
Yasir Khan
 
Lecture 4
Lecture 4
Yasir Khan
 
Lecture 3
Lecture 3
Yasir Khan
 
Lecture 2
Lecture 2
Yasir Khan
 
Lec#1
Lec#1
Yasir Khan
 
Ch10 (1)
Ch10 (1)
Yasir Khan
 
Ch09
Ch09
Yasir Khan
 
Ch05
Ch05
Yasir Khan
 
Snooping protocols 3
Snooping protocols 3
Yasir Khan
 
Snooping 2
Snooping 2
Yasir Khan
 
Introduction 1
Introduction 1
Yasir Khan
 
Hpc sys
Hpc sys
Yasir Khan
 
Hpc 6 7
Hpc 6 7
Yasir Khan
 
Hpc 4 5
Hpc 4 5
Yasir Khan
 
Hpc 3
Hpc 3
Yasir Khan
 
Hpc 2
Hpc 2
Yasir Khan
 
Hpc 1
Hpc 1
Yasir Khan
 
Flynns classification
Flynns classification
Yasir Khan
 
Dir based imp_5
Dir based imp_5
Yasir Khan
 
Natural Language Processing
Natural Language Processing
Yasir Khan
 
Ad

Recently uploaded (17)

16 Billions Google Leaked Password Alert in 2025
16 Billions Google Leaked Password Alert in 2025
Harshh Goel
 
Hasta la vista sota vita la humour.pptx
Hasta la vista sota vita la humour.pptx
JohnAsir4
 
Dana Guerin - A Film Producer And Philanthropist
Dana Guerin - A Film Producer And Philanthropist
Dana Guerin
 
silver_linings_playbook the movie the movie
silver_linings_playbook the movie the movie
VernonSmap
 
SpeakOut_TeachersBook_Advanced_PlusEdition.pdf
SpeakOut_TeachersBook_Advanced_PlusEdition.pdf
agustolosa93
 
PRESENTATION ON DYANAM YOGA BRAIN HEART SOUL
PRESENTATION ON DYANAM YOGA BRAIN HEART SOUL
VenkatDeepakSarma
 
Jordan Minnesota - The Town Where Your Diet Comes to Die
Jordan Minnesota - The Town Where Your Diet Comes to Die
Forklift Trucks in Minnesota
 
Strategy & Survival in Aliens Another Glorious Day in the Corps!
Strategy & Survival in Aliens Another Glorious Day in the Corps!
BoardGamesNMore
 
tiranga ritik baclink indexing on google
tiranga ritik baclink indexing on google
Jalwa Game
 
原版一样(IWU毕业证书)美国印第安纳卫斯里大学毕业证在线购买
原版一样(IWU毕业证书)美国印第安纳卫斯里大学毕业证在线购买
taqyed
 
办理学历认证USC学生证西班牙圣地亚哥德孔波斯特拉大学电子毕业证,USC成绩单防伪
办理学历认证USC学生证西班牙圣地亚哥德孔波斯特拉大学电子毕业证,USC成绩单防伪
Taqyea
 
在线购买西班牙毕业证安东尼奥·德·内夫里哈大学文凭UANE学费单
在线购买西班牙毕业证安东尼奥·德·内夫里哈大学文凭UANE学费单
Taqyea
 
The Bet - Concept Teaser v06 Storyboards
The Bet - Concept Teaser v06 Storyboards
Jim Mortensen
 
Breaking the Romance Narrative – Why I Wrote “Hello”
Breaking the Romance Narrative – Why I Wrote “Hello”
itstriggerhere
 
Top 1 app watch girls livestream (1).docx
Top 1 app watch girls livestream (1).docx
jonhsey0009
 
Rice Genomics & Whole Genome Sequencing.pptx
Rice Genomics & Whole Genome Sequencing.pptx
LikhithHR
 
仿制CSUS学费单美国加利福尼亚州立大学萨克拉门托分校毕业证范本,CSUS文凭
仿制CSUS学费单美国加利福尼亚州立大学萨克拉门托分校毕业证范本,CSUS文凭
taqyed
 
16 Billions Google Leaked Password Alert in 2025
16 Billions Google Leaked Password Alert in 2025
Harshh Goel
 
Hasta la vista sota vita la humour.pptx
Hasta la vista sota vita la humour.pptx
JohnAsir4
 
Dana Guerin - A Film Producer And Philanthropist
Dana Guerin - A Film Producer And Philanthropist
Dana Guerin
 
silver_linings_playbook the movie the movie
silver_linings_playbook the movie the movie
VernonSmap
 
SpeakOut_TeachersBook_Advanced_PlusEdition.pdf
SpeakOut_TeachersBook_Advanced_PlusEdition.pdf
agustolosa93
 
PRESENTATION ON DYANAM YOGA BRAIN HEART SOUL
PRESENTATION ON DYANAM YOGA BRAIN HEART SOUL
VenkatDeepakSarma
 
Jordan Minnesota - The Town Where Your Diet Comes to Die
Jordan Minnesota - The Town Where Your Diet Comes to Die
Forklift Trucks in Minnesota
 
Strategy & Survival in Aliens Another Glorious Day in the Corps!
Strategy & Survival in Aliens Another Glorious Day in the Corps!
BoardGamesNMore
 
tiranga ritik baclink indexing on google
tiranga ritik baclink indexing on google
Jalwa Game
 
原版一样(IWU毕业证书)美国印第安纳卫斯里大学毕业证在线购买
原版一样(IWU毕业证书)美国印第安纳卫斯里大学毕业证在线购买
taqyed
 
办理学历认证USC学生证西班牙圣地亚哥德孔波斯特拉大学电子毕业证,USC成绩单防伪
办理学历认证USC学生证西班牙圣地亚哥德孔波斯特拉大学电子毕业证,USC成绩单防伪
Taqyea
 
在线购买西班牙毕业证安东尼奥·德·内夫里哈大学文凭UANE学费单
在线购买西班牙毕业证安东尼奥·德·内夫里哈大学文凭UANE学费单
Taqyea
 
The Bet - Concept Teaser v06 Storyboards
The Bet - Concept Teaser v06 Storyboards
Jim Mortensen
 
Breaking the Romance Narrative – Why I Wrote “Hello”
Breaking the Romance Narrative – Why I Wrote “Hello”
itstriggerhere
 
Top 1 app watch girls livestream (1).docx
Top 1 app watch girls livestream (1).docx
jonhsey0009
 
Rice Genomics & Whole Genome Sequencing.pptx
Rice Genomics & Whole Genome Sequencing.pptx
LikhithHR
 
仿制CSUS学费单美国加利福尼亚州立大学萨克拉门托分校毕业证范本,CSUS文凭
仿制CSUS学费单美国加利福尼亚州立大学萨克拉门托分校毕业证范本,CSUS文凭
taqyed
 

Console programms

  • 1. Programs Are Compiled By: Yasir Ahmed Khan | [email protected] | 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 | [email protected] | 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 | [email protected] | 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 | [email protected] | 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 | [email protected] | 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 | [email protected] | 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 | [email protected] | 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 | [email protected] | 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 | [email protected] | 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 | [email protected] | 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 | [email protected] | 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 | [email protected] | 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);