You are on page 1of 62

ASSIGNMENT

“PROGRAMMING
FUNDAMENTALS”
• SUBMITTED BY:
•SIDRA
R.N: BASHIR
BT15012
•SUBMITTED
•TO:
SIR IRFAN
//Q#1 R.BT15012 N.B.Sidra S.A.M

A. #include<iostream.h>

#include<conio.h>

void main()

int r,area,circumference;

clrscr();

cout<<"Enter radius = ";

cin>> r;

area=3.14*r*r;

cout<<" Area is = "<<area<<endl;

circumference=2*3.14*r*r;

cout<<" Circumference is = "<<circumference<<endl;

getch();

}
//Q#2 R.BT15012 N.B.Sidra S.A.M

#include<iostream.h>

#include<conio.h>

void main()

int inches,centimeter,height;

clrscr();

cout<<" Enter height in inches = ";

cin>> inches;

centimeter=2.54*height;

cout<<" Height in centimeter is "<<centimeter<<endl;

getch();

//Q#3 R.BT15012 N.B.Sidra S.A.M

#include<iostream.h>

#include<conio.h>

void main()

int feet,inches,meter,height;

clrscr();

cout<<" Enter height in inches = ";

cin>> height;

feet=inches/12;
cout<<" Height in feet is = "<<feet<<endl;

meter=feet/39;

cout<<" Height in meter is = "<<meter<<endl;

getch();

//Q#4 R.BT15012 N.B.Sidra S.A.M

#include<iostream.h>

#include<conio.h>

void main()

int s,vi,a,t;

clrscr();

cout<<" Enter velocity = ";

cin>> vi;

cout<<" Enter time = ";

cin>> t;

cout<<" Enter accelration = ";

cin>> a;

s=vi*t+1/2*a*t*t;

cout<<" Distance covered by applying third equation is = "<<s<<endl;

getch();

}
//Q#5 R.BT15012 N.B.Sidra S.A.M

#include<iostream.h>

#include<conio.h>

void main()

int
salaries,rent_of_building,electricity_charges,carriage,purchases,interest_paid,commission_paid,wages,dearness_allowance,packing_charges,sal
es,commission_received,interest_received,discount_received,rent_received;

float profit,loss,total_expenses,total_revenues;

clrscr();

cout<<" Enter salaries = ";

cin>> salaries;

cout<<" Enter rent of building = ";

cin>> rent_of_building;

cout<<" Enter electricity charges = ";

cin>> electricity_charges;

cout<<" Enter carriage = ";

cin>> carriage;

cout<<" Enter purchases = ";

cin>> purchases;

cout<<" Enter interest paid = ";

cin>> interest_paid;

cout<<" Enter commission paid = ";

cin>> commission_paid;

cout<<" Enter wages = ";


cin>> wages;

cout<<" Enter dearness allowance = ";

cin>> dearness_allowance;

cout<<" Enter packing charges = ";

cin>> packing_charges;

cout<<" Enter sales = ";

cin>> sales;

cout<<" Enter commission received = ";

cin>> commission_received;

cout<<" Enter interest received = ";

cin>> interest_received;

cout<<" Enter discount received = ";

cin>> discount_received;

cout<<" Enter rent received = ";

cin>> rent_received;

total_expenses=salaries+rent_of_building+electricity_charges+carriage+purchases+interest_paid+commission_paid+dearness_allowance+packi
ng_charges;

cout<<" Total expenses are = "<<total_expenses<<endl;

cout<<endl;

total_revenues=sales+commission_received+interest_received+discount_received+rent_received;

cout<<" Total revenues are = "<<total_expenses<<endl;

cout<<endl;

loss=total_expenses-total_revenues;

profit=total_revenues-total_expenses;

if(total_expenses>total_revenues)

cout<<" Profit is = "<<profit<<endl;

else if(total_expenses<total_revenues)

cout<<" Loss is = "<<loss<<endl;


else

cout<<" No profit no loss = "<<endl;

getch();

//Q#6 R.BT15012 N.B.Sidra S.A.M

#include<iostream.h>

#include<conio.h>

void main()

clrscr();

cout<<" PROGRAM TO CALCULATE ORIGNAL LOAN "<<endl;

cout<<" INTEREST AND LOAN AFTER INTEREST "<<endl;

cout<<endl<<endl;

cout<<"******************************************************"<<endl;

float rate,year,loan,interest,month,amount;

cout<<" enter amount of loan = ";

cin>>loan;

cout<<" interest rate in percentage = ";

cin>>rate;

cout<<" enter duration in months = ";

cin>>month;

year=month/12;
interest=loan*year*(rate/100);

amount=loan+interest;

cout<<endl<<endl;

clrscr();

cout<<" FINAL RESULT "<<endl;

cout<<"______________________________________________________"<<endl;

cout<<" the original amount of loan is = "<<loan<<endl;

cout<<" amount of interst = "<<interest<<endl;

cout<<" amount of interst after loan = "<<amount;

cout<<endl<<endl<<endl;

cout<<"*******************************************************";

getch();

//Q#7 R.BT15012 N.B.Sidra S.A.M

#include<iostream.h>

#include<conio.h>

#include<math.h>

void main()

clrscr();

int a,b,c,d,e;

a=1;

b=2;
c=3;

d=4;

e=5;

cout<<"Number\tSquare\tCube "<<endl;

cout<<"------\t------\t------- "<<endl;

cout<<a<<"\t"<<pow(a,2)<<"\t"<<pow(a,3)<<endl<<endl<<b<<"\t"<<pow(b,2)<<"\t"<<pow(b,3)<<endl<<endl<<c<<"\t"<<pow(c,2)<<"\t"<<pow
(c,3)<<endl<<endl<<d<<"\t"<<pow(d,2)<<"\t"<<pow(d,3)<<endl<<endl<<e<<"\t"<<pow(e,2)<<"\t"<<pow(e,3)<<endl<<endl;

getch();

//Q#8(a) R.BT15012 N.B.Sidra S.A.M

#include<iostream.h>

#include<conio.h>

void main()

clrscr();

long temprature,celsius,fahrenheit;

cout<<" TEMPRATURE IN CELSIUS "<<endl;

cout<<endl;

cout<<" ******************************* "<<endl;

cout<<" Enter temprature = ";

cin>> temprature;

celsius=(fahrenheit-32)*5/9;

cout<<" Temprature in celsius = "<<celsius<<endl;

getch();
}

//Q#8(b) R.BT15012 N.B.Sidra S.A.M

#include<iostream.h>

#include<conio.h>

void main()

float tamprature,fahrenheit,celsius;

clrscr();

cout<<" TEMPRATURE IN FAHRENHEIT "<<endl;

cout<<endl;

cout<<" ****************************************** "<<endl;

cout<<" Enter tamprature in celsius = ";

cin>> tamprature;

fahrenheit=celsius*9.0/5.0+32;

cout<<" Temprature in fahrenheit is = "<<fahrenheit<<endl;

getch();

//Q#9(1) R.BT15012 N.B.Sidra .S.A.M

#include<iostream.h>

#include<conio.h>

void main()

{
int a,b;

clrscr();

cout<<" Enter first number = ";

cin>> a;

cout<<" Enter second number = ";

cin>>b;

if(a>b||b>a)

cout<<" Numbers are not equal "<<endl;

else

cout<<" Number are equal "<<endl;

getch();

//Q#9(2) R.BT15012 R.B.Sidra S.A.M

#include<iostream.h>

#include<conio.h>

void main()

int a,b;

clrscr();

cout<<" CHECK WETHER THE SECOND NUMBER IS SQUARE OF FIRST NUMBER "<<endl;

cout<<endl;

cout<<" *************************************************************"<<endl;

cout<<" Enter first number = ";

cin>> a;
cout<<" Enter second number = ";

cin>> b;

if(a*a==b)

cout<<" Second number is square of first number : "<<endl;

else

cout<<" Second number is not the square of first : "<<endl;

getch();

//Q#9(3) R.BT15012 N.B.Sidra S.A.M

#include<iostream.h>

#include<conio.h>

void main()

int a,b,c,d;

clrscr();

cout<<endl;

cout<<" DISPLATY MAXIMUM NUMBER "<<endl;

cout<<endl;

cout<<" *********************************** "<<endl;

cout<<endl;

cout<<" Enter first number = ";

cin>> a;

cout<<" Enter second number = ";


cin>> b;

cout<<" Enter third number = ";

cin>> c;

cout<<" Enter fourth number = ";

cin>> d;

cout<<endl<<endl;

if(a>b && a>b && a>c && a>d)

cout<<" Mwximum number is a : "<<a<<endl;

else if(b>a && b>c && b>d)

cout<<" Maximum number is b : "<<b<<endl;

else if(c>a && c>b && c>d)

cout<<" Maximum number is c : "<<c<<endl;

else

cout<<" Maximum number is d : "<<d<<endl;

getch();

//Q#9(4) R.BT15012 N.B.Sidra S.A.M

#include<iostream.h>

#include<conio.h>

void main()

int a,b,c,d;
clrscr();

cout<<endl;

cout<<" DISPLATY MINIMUM NUMBER "<<endl;

cout<<endl;

cout<<" *********************************** "<<endl;

cout<<endl;

cout<<" Enter first number = ";

cin>> a;

cout<<" Enter second number = ";

cin>> b;

cout<<" Enter third number = ";

cin>> c;

cout<<" Enter fourth number = ";

cin>> d;

cout<<endl<<endl;

if(a<b && a<c && a<d)

cout<<" Minimum number is a : "<<a<<endl;

else if(b<a && b<c && b<d)

cout<<" Minimum number is b : "<<b<<endl;

else if(c<a && c<b && c<d)

cout<<" Minimum number is c : "<<c<<endl;

else

cout<<" Minimum number is d : "<<d<<endl;

getch();

}
//Q#9(5) R.BT15012 N.B.Sidra S.A.M

#include<iostream.h>

#include<conio.h>

void main()

int n;

clrscr();

cout<<endl;

cout<<" ENTERED NUMBER IS POSITIVE NEGATIVE OR ZERO "<<endl;

cout<<endl;

cout<<" ************************************* "<<endl;

cout<<endl;

cout<<" Enter a number = ";

cin>> n;

if(n>0)

cout<<" Number is positive : "<<endl;

else if(n<0)

cout<<" Number is negative : "<<endl;

else

cout<<" Number is zero : "<<endl;

getch();

}
//Q#9(6) R.BT15012 N.B.Sidra S.A.M

#include<iostream.h>

#include<conio.h>

void main()

int n;

clrscr();

cout<<endl;

cout<<" WELCOME TO CHECK NUMBER IS EVEN OR ODD "<<endl;

cout<<endl;

cout<<" *********************************************** "<<endl;

cout<<endl;

cout<<" Enter any number = ";

cin>> n;

if(n%2==0)

cout<<" Number is even "<<n<<endl;

else

cout<<" Number is odd "<<n<<endl;


getch();

//Q#9(7) R.BT15012 N.B.Sidra S.A.M

#include<iostream.h>

#include<conio.h>

void main()

double salary,bonous,net_salary,grade;

clrscr();

cout<<endl;

cout<<" TOTAL SALARY OF THE EMPLOYEE "<<endl;

cout<<endl;

cout<<" ************************************* "<<endl;

cout<<endl;

cout<<" Enter basic salary of the employee = ";

cin>> salary;

cout<<" Enter grade of the employee = ";

cin>> grade;

if(grade>=19)

bonous=salary*70/100;

else if(grade>=16)

bonous=salary*40/100;

else

bonous=0;

net_salary=bonous+salary;

cout<<" total salary is = "<<net_salary<<endl;


getch();

//Q#9(8) R.BT15012 N.B.Sidra S.A.M

#include<iostream.h>

#include<conio.h>

void main()

clrscr();

int english,urdu,math,I_study,P_study,physics,chemistry,bio,total;

float average;

cout<<endl;

cout<<" RESULT CARD "<<endl;

cout<<endl;

cout<<" 10th CLASS "<<endl;

cout<<endl;

cout<<" ***************************** "<<endl;

cout<<" Enter marks of english = ";

cin>> english;

cout<<" Enter marks of urdu = ";

cin>> urdu;

cout<<" Enter marks of math = ";

cin>> math;

cout<<" Enter marks of I_study = ";

cin>> I_study;

cout<<" Enter marks of P_study = ";

cin>> P_study;

cout<<" Enter marks of physics = ";


cin>> physics;

cout<<" Enter marks of bio = ";

cin>> bio;

cout<<" Enter marks of chemistry = ";

cin>> chemistry;

if(english>=80)

cout<<" Grade is A+ : "<<endl;

else if(english>=70)

cout<<" Grade is A : "<<endl;

else if(english>=60)

cout<<" Grade is B : "<<endl;

else if(english>=50)

cout<<" Grade is C : "<<endl;

else if(english>=45)

cout<<" Grade is D : "<<endl;

else if(english>=40)

cout<<" Grade is E : "<<endl;

else if(english>=33)

cout<<" Grade is F : "<<endl;

else

cout<<" Reapear : "<<endl;

cout<<endl<<endl;

if(urdu>=80)

cout<<" Grade is A+ : "<<endl;

else if(urdu>=70)

cout<<" Grade is A : "<<endl;

else if(urdu>=60)

cout<<" Grade is B : "<<endl;

else if(urdu>=50)
cout<<" Grade is C : "<<endl;

else if(urdu>=45)

cout<<" Grade is D : "<<endl;

else if(urdu>=40)

cout<<" Grade is E : "<<endl;

else if(urdu>=33)

cout<<" Grade is F : "<<endl;

else

cout<<" Reapear : "<<endl;

cout<<endl<<endl;

if(math>=80)

cout<<" Grade is A+ : "<<endl;

else if(math>=70)

cout<<" Grade is A : "<<endl;

else if(math>=60)

cout<<" Grade is B : "<<endl;

else if(math>=50)

cout<<" Grade is C : "<<endl;

else if(math>=45)

cout<<" Grade is D : "<<endl;

else if(math>=40)

cout<<" Grade is E : "<<endl;

else if(math>=33)

cout<<" Grade is F : "<<endl;

else

cout<<" Reapear : "<<endl;

cout<<endl<<endl;

if(I_study>=80)

cout<<" Grade is A+ : "<<endl;


else if(I_study>=70)

cout<<" Grade is A : "<<endl;

else if(I_study>=60)

cout<<" Grade is B : "<<endl;

else if(I_study>=50)

cout<<" Grade is C : "<<endl;

else if(I_study>=45)

cout<<" Grade is D : "<<endl;

else if(I_study>=40)

cout<<" Grade is E : "<<endl;

else if(I_study>=33)

cout<<" Grade is F : "<<endl;

else

cout<<" Reapear : "<<endl;

cout<<endl<<endl;

if(P_study>=80)

cout<<" Grade is A+ : "<<endl;

else if(P_study>=70)

cout<<" Grade is A : "<<endl;

else if(P_study>=60)

cout<<" Grade is B : "<<endl;

else if(P_study>=50)

cout<<" Grade is C : "<<endl;

else if(P_study>=45)

cout<<" Grade is D : "<<endl;

else if(P_study>=40)

cout<<" Grade is E : "<<endl;

else if(P_study>=33)

cout<<" Grade is F : "<<endl;


else

cout<<" Reapear : "<<endl;

cout<<endl<<endl;

if(physics>=80)

cout<<" Grade is A+ : "<<endl;

else if(physics>=70)

cout<<" Grade is A : "<<endl;

else if(physics>=60)

cout<<" Grade is B : "<<endl;

else if(physics>=50)

cout<<" Grade is C : "<<endl;

else if(physics>=45)

cout<<" Grade is D : "<<endl;

else if(physics>=40)

cout<<" Grade is E : "<<endl;

else if(physics>=33)

cout<<" Grade is F : "<<endl;

else

cout<<" Reapear : "<<endl;

cout<<endl<<endl;

if(bio>=80)

cout<<" Grade is A+ : "<<endl;

else if(bio>=70)

cout<<" Grade is A : "<<endl;

else if(bio>=60)

cout<<" Grade is B : "<<endl;

else if(bio>=50)

cout<<" Grade is C : "<<endl;

else if(bio>=45)
cout<<" Grade is D : "<<endl;

else if(bio>=40)

cout<<" Grade is E : "<<endl;

else if(bio>=33)

cout<<" Grade is F : "<<endl;

else

cout<<" Reapear : "<<endl;

cout<<endl<<endl;

if(chemistry>=80)

cout<<" Grade is A+ : "<<endl;

else if(chemistry>=70)

cout<<" Grade is A : "<<endl;

else if(chemistry>=60)

cout<<" Grade is B : "<<endl;

else if(chemistry>=50)

cout<<" Grade is C : "<<endl;

else if(chemistry>=45)

cout<<" Grade is D : "<<endl;

else if(chemistry>=40)

cout<<" Grade is E : "<<endl;

else if(chemistry>=33)

cout<<" Grade is F : "<<endl;

else

cout<<" Reapear : "<<endl;

cout<<endl<<endl;

total=english+bio+physics+chemistry+math+I_study+P_study+urdu;

cout<<" sum of all books is = "<<total<<endl;

average=total/8*100;

cout<<" Average is = "<<average<<endl;


cout<<endl;

cout<<endl;

if(total>=80)

cout<<" Grade is A+ : "<<endl;

else if(total>=70)

cout<<" Grade is A : "<<endl;

else if(total>=60)

cout<<" Grade is B : "<<endl;

else if(total>=50)

cout<<" Grade is C : "<<endl;

else if(total>=45)

cout<<" Grade is D : "<<endl;

else if(total>=40)

cout<<" Grade is E : "<<endl;

else if(total>=33)

cout<<" Grade is F : "<<endl;

else

cout<<" Reapear : "<<endl;

getch();

}
//Q#9(9) R.BT15012 N.B.SIDRA S.A.M

#include<iostream.h>

#include<conio.h>

void main()

int roll_num, programing, com, workshop, calculus, e_m;

float p_points, c_points, w_points, cal_points, e_points,total,GPA;

char name[10];

clrscr();

cout<<endl<<endl;

cout<<" GPA CALCULATOR "<<endl;

cout<<endl;

cout<<" *************************************** "<<endl;

cout<<endl;

cout<<" Enter name of student : ";

cin>> name;

cout<<" Enter roll number of : ";

cin>> roll_num;

cout<<endl<<endl;

cout<<" CALCULUS "<<endl;

cout<<endl;

cout<<" *************************************** "<<endl;

cout<<endl;

cout<<" Enter marks of calculus = ";


cin>> calculus ;

cout<<endl;

if(calculus>=85){

cout<<" Grade of calculus is A " <<endl;}

else if(calculus>=80){

cout<<" Grade of calculus is A- "<<endl;}

else if(calculus>=75){

cout<<" Grade of calculus is B+ "<<endl;}

else if(calculus>=70){

cout<<" Grade of calculus is B "<<endl;}

else if(calculus>=65){

cout<<" Grade of calculus is B- "<<endl;}

else if(calculus>=61){

cout<<" Grade of calculus is C+ "<<endl;}

else if(calculus>=58){

cout<<" Grade of calculus is C "<<endl;}

else if(calculus>=55){

cout<<" Grade of calculus is C- "<<endl;}

else if(calculus>=50){

cout<<" Grade of calculus is D "<<endl;}

else

cout<<" Grade of calculus is F "<<endl;

cout<<endl<<endl;

if(calculus>=85){

cal_points=4.00;

cout<<" garde points are = "<<cal_points<<endl;}


else if(calculus>=80){

cal_points=3.70;

cout<<" grade points are = "<<cal_points<<endl;}

else if(calculus>=75){

cal_points=3.30;

cout<<" grade points are = "<<cal_points<<endl;}

else if(calculus>=70){

cal_points=3.00;

cout<<" grade points are = "<<cal_points<<endl;}

else if(calculus>=65){

cal_points=2.70;

cout<<" grade points are = "<<cal_points<<endl;}

else if(calculus>=61){

cal_points=2.30;

cout<<" grade points are = "<<cal_points<<endl;}

else if(calculus>=58){

cal_points=2.00;

cout<<" grade points are = "<<cal_points<<endl;}

else if(calculus>=55){

cal_points=1.70;

cout<<" grade points are = "<<cal_points<<endl;}

else if(calculus>=50){

cal_points=1.00;

cout<<" grade points are = "<<cal_points<<endl;}

else{

cal_points=0.00;

cout<<" grade points are = "<<cal_points<<endl;}

cout<<endl<<endl;
cout<<" WRITING WORKSHOP "<<endl;

cout<<endl;

cout<<" ********************************* "<<endl;

cout<<endl;

cout<<" Enter marks of english = ";

cin>> workshop ;

cout<<endl;

if(workshop>=85)

cout<<" Grade of workshop writing is A " <<endl;

else if(workshop>=80)

cout<<" Grade of writing workshop is A- "<<endl;

else if(workshop>=75)

cout<<" Grade of writing workshop is B+ "<<endl;

else if(workshop>=70)

cout<<" Grade of writing workshop is B "<<endl;

else if(workshop>=65)

cout<<" Grade of writing workshop is B- "<<endl;

else if(workshop>=61)

cout<<" Grade of writing workshop is C+ "<<endl;

else if(workshop>=58)

cout<<" Grade of workshop writing is C "<<endl;

else if(workshop>=55)

cout<<" Grade of workshop writing is C- "<<endl;

else if(workshop>=50)

cout<<" Grade of workshop writing is D "<<endl;

else

cout<<" Grade of workshop writing is F "<<endl;


}

cout<<endl<<endl;

if(workshop>=85)

w_points=4.00;

else if(workshop>=80)

w_points=3.70;

else if(workshop>=75)

w_points=3.30;

else if(workshop>=70)

w_points=3.00;

else if(workshop>=65)

w_points=2,70;

else if(workshop>=61)

w_points=2.30;

else if(workshop>=58)

w_points=2.00;

else if(workshop>=55)

w_points=1.70;

else if(workshop>=50)

w_points=1.00;

else

w_points=0.00;

cout<<endl<<endl;

cout<<endl;

cout<<" PROGRAMING "<<endl;


cout<<endl;

cout<<" ****************************** "<<endl;

cout<<endl;

cout<<" Enter mar1ks of programing = ";

cin>> programing ;

cout<<endl;

if(programing>=85)

cout<<" Grade of programing is A " <<endl;

else if(programing>=80)

cout<<" Grade of programing is A- "<<endl;

else if(programing>=75)

cout<<" Grade of programing is B+ "<<endl;

else if(programing>=70)

cout<<" Grade of programing is B "<<endl;

else if(programing>=65)

cout<<" Grade of programing is B- "<<endl;

else if(programing>=61)

cout<<" Grade of programing is C+ "<<endl;

else if(programing>=58)

cout<<" Grade of programing is C "<<endl;

else if(programing>=55)

cout<<" Grade of programing is C- "<<endl;

else if(programing>=50)

cout<<" Grade of programing is D "<<endl;

else

cout<<" Grade of programing is F "<<endl;

}
cout<<endl<<endl;

if(programing>=85)

p_points=4.00;

else if(programing>=80)

p_points=3.70;

else if(programing>=75)

p_points=3.30;

else if(programing>=70)

p_points=3.00;

else if(programing>=65)

p_points=2,70;

else if(programing>=61)

p_points=2.30;

else if(programing>=58)

p_points=2.00;

else if(programing>=55)

p_points=1.70;

else if(programing>=50)

p_points=1.00;

else

p_points=0.00;

cout<<endl<<endl;

cout<<endl;

cout<<" INTRODUCTION to COMPUTING "<<endl;

cout<<endl;
cout<<" ******************************** "<<endl;

cout<<endl;

cout<<" Enter marks of computing = ";

cin>> com ;

cout<<endl;

if(com>=85)

cout<<" Grade of computing is A " <<endl;

else if(com>=80)

cout<<" Grade of computing is A- "<<endl;

else if(com>=75)

cout<<" Grade of computing is B+ "<<endl;

else if(com>=70)

cout<<" Grade of computing is B "<<endl;

else if(com>=65)

cout<<" Grade of computing is B- "<<endl;

else if(com>=61)

cout<<" Grade of computing is C+ "<<endl;

else if(com>=58)

cout<<" Grade of computing is C "<<endl;

else if(com>=55)

cout<<" Grade of computing is C- "<<endl;

else if(com>=50)

cout<<" Grade of computing is D "<<endl;

else

cout<<" Grade of computing is F "<<endl;

}
cout<<endl<<endl;

if(com>=85)

c_points=4.00;

else if(com>=80)

c_points=3.70;

else if(com>=75)

c_points=3.30;

else if(com>=70)

c_points=3.00;

else if(com>=65)

c_points=2,70;

else if(com>=61)

c_points=2.30;

else if(com>=58)

c_points=2.00;

else if(com>=55)

c_points=1.70;

else if(com>=50)

c_points=1.00;

else

c_points=0.00;

cout<<endl<<endl;

cout<<endl;

cout<<" ELECTRO MEGNATISIM "<<endl;

cout<<endl;

cout<<" ******************************** "<<endl;


cout<<endl;

cout<<" Enter marks of electro mgnatisim = ";

cin>> e_m ;

cout<<endl;

if(e_m>=85)

cout<<" Grade of electro megnatisim is A " <<endl;

else if(e_m>=80)

cout<<" Grade of electro megnatisim is A- "<<endl;

else if(e_m>=75)

cout<<" Grade of electro megnatisim is B+ "<<endl;

else if(e_m>=70)

cout<<" Grade of electro megnatisim is B "<<endl;

else if(e_m>=65)

cout<<" Grade of electro megnatisim is B- "<<endl;

else if(e_m>=61)

cout<<" Grade of elestro megnatisim is C+ "<<endl;

else if(e_m>=58){

cout<<" Grade of electro megnatisim is C "<<endl;}

else if(e_m>=55)

cout<<" Grade of electro megnatisim is C- "<<endl;

else if(e_m>=50)

cout<<" Grade of electro megnatisim is D "<<endl;

else

cout<<" Grade of electro megnatisim is F "<<endl;

cout<<endl<<endl;

if(e_m>=85)
e_points=4.00;

else if(e_m>=80)

e_points=3.70;

else if(e_m>=75)

e_points=3.30;

else if(e_m>=70)

e_points=3.00;

else if(e_m>=65)

e_points=2,70;

else if(e_m>=61)

e_points=2.30;

else if(e_m>=58)

e_points=2.00;

else if(e_m>=55)

e_points=1.70;

else if(e_m>=50)

e_points=1.00;

else

e_points=0.00;

cout<<endl<<endl;

total=e_points+p_points+cal_points+c_points+w_points;

cout<<" Total is = "<<total<<endl;

GPA=total/5;

cout<<endl<<endl;

cout<<" FINAL GPA IS "<<endl;

cout<<" ********************** "<<endl;

clrscr();
cout<<" GPA is = "<<GPA<<endl;

cout<<endl;

getch();

//Q#10 R.BT15012 N.B.SIDRA S.A.M

#include<iostream.h>

#include<conio.h>

void main()

clrscr();

int grade,ac,con,senior;

float salary,t_salary,n_salary,tax,tt_salary;

char name[100],city[100];

cout<<" Employees Record of Talon Sports Company ptv.ltd "<<endl;

cout<<"*********************************************************"<<endl;

cout<<endl<<endl<<endl;

cout<<" enter name of employee = ";

cin>>name;

cout<<" enter city of employee = ";

cin>>city;

cout<<" enter pay scale of employee = ";

cin>>grade;

cout<<" enter salary of employee = ";

cin>>salary;

cout<<" accommodation allowance of "<<name<<" = ";

cin>>ac;

cout<<" conveyance allowane of "<<name<<" = ";

cin>>con;
cout<<endl;

if(grade>=20)

senior=20000;

else if(grade>=18)

senior=14000;

else if(grade>=16)

senior=9000;

else if(grade>=14)

senior=5000;

else

senior=0;

t_salary=salary+ac+con+senior;

tt_salary=t_salary*12;

clrscr();

cout<<endl<<endl;

cout<<" you have the entered following Records And Net salary is Following "<<endl<<endl<<endl;

cout<<"*********************************************************************"<<endl;

cout<<endl<<endl<<endl;

cout<<" Name : "<<name<<endl;

cout<<" City : "<<city<<endl;

cout<<" Grade : "<<grade<<endl;

cout<<" Salary : "<<salary<<endl;

cout<<" Total salary of "<<name<<" per month is = "<<t_salary<<endl;

cout<<" total salary of "<<name<<" per annum is = "<<tt_salary;

cout<<endl;

if(tt_salary>=7000000)

tax=tt_salary*30/100;

else if(tt_salary>=4000000)
tax=tt_salary*27.5/100;

else if(tt_salary>= 3500000)

tax=tt_salary*25/100;

else if(tt_salary>= 3000000)

tax=tt_salary*22.5/100;

else if(tt_salary>= 2500000)

tax=tt_salary*20/100;

else if(tt_salary>= 1800000)

tax=tt_salary*17.5/100;

else if(tt_salary>= 1500000)

tax=tt_salary*15/100;

else if(tt_salary>= 1400000)

tax=tt_salary*12.5/100;

else if(tt_salary>= 750000)

tax=tt_salary*10/100;

else if(tt_salary>= 500000)

tax=tt_salary*5/100;

else if(tt_salary>= 400000)

tax=tt_salary*2/100;

else

tax=0;

n_salary=tt_salary-tax;

cout<<" net salary of "<<name<<" after "<<tax<<" tax is : "<<n_salary;

getch();

}
//Q#11 R.BT15012 N.B.SIDRA S.A.M

#include<iostream.h>

#include<conio.h>

void main()

int n;

clrscr();

cout<<" NUMBER OF WEAK DAY'S "<<endl;

cout<<" ********************************* "<<endl;

cout<<" Enter week's day = ";

cin>> n;

switch(n)

case 1:

cout<<" MONDAY "<<endl;

break;

case 2:

cout<<" TUESDAY "<<endl;

break;

case 3:

cout<<" WEDNESDAY "<<endl;

break;

case 4:

cout<<" THURSDAY "<<endl;

break;

case 5:

cout<<" FRIDAY "<<endl;

break;
case 6:

cout<<" SATURDAY "<<endl;

break;

case 7:

cout<<" SUNDAY "<<endl;

break;

dafult:

cout<<" INvalid input "<<endl;

getch();

//Q#12 R.BT15012 N.B.Sidra S.A.M

#include<iostream.h>

#include<conio.h>

#include<stdlib.h>

void main()

while(1)

clrscr();

int choice;

cout<<" WEICOME TO SEE MONTH'S NAME "<<endl;

cout<<endl<<endl;

cout<<" ********************************* "<<endl;

cout<<" Enter any number from (1 to 12) to chek month's name "<<endl;
cout<<" Press 13 to exit ";

cin>> choice;

switch(choice)

case 1:

cout<<" THIS IS JANUARY : "<<endl;

break;

case 2:

cout<<" THIS IS FEBRARY : "<<endl;

break;

case 3:

cout<<" THIS IS MARCH : "<<endl;

break;

case 4:

cout<<" THIS IS APRIL : "<<endl;

break;

case 5:

cout<<" THIS IS MAY : "<<endl;

break;

case 6:

cout<<" THIS IS JUNE : "<<endl;

break;

case 7:

cout<<" THIS IS JULY : "<<endl;

break;

case 8:

cout<<" THIS IS AUGUST : "<<endl;

break;

case 9:
cout<<" THIS IS SEPTEMBER : "<<endl;

break;

case 10:

cout<<" THIS IS OCTOBER : "<<endl;

break;

case 11:

cout<<" THIS IS NOVEMBER : "<<endl;

break;

case 12:

cout<<" THIS IS DECEMBER : "<<endl;

case 13:

exit(0);

dafult:

cout<<" INVALID INPUT : "<<endl;

getch();

getch();

clrscr();

getch();

//Q#13 R.BT15012 N.B.Sidra S.A.M

#include<iostream.h>
#include<conio.h>

#include<stdlib.h>

void main()

while(1)

int choice;

clrscr();

cout<<" SEE THE NUMBER OF DAYS IN A MONTH "<<endl;

cout<<endl<<endl;

cout<<" **************************************** "<<endl;

cout<<" Enter 1 for january "<<endl;

cout<<" Enter 2 for febrary "<<endl;

cout<<" Enter 3 for march "<<endl;

cout<<" Enter 4 for april "<<endl;

cout<<" Enter 5 for may "<<endl;

cout<<" Enter 6 for june "<<endl;

cout<<" Enter 7 for july "<<endl;

cout<<" Enter 8 for august "<<endl;

cout<<" Enter 9 for september "<<endl;

cout<<" Enter 10 for october "<<endl;

cout<<" Enter 11 for novembar "<<endl;

cout<<" Enter 12 for decembar "<<endl;

cout<<" Enter 13 to exit "<<endl;

cin>> choice;

switch(choice)

{
case 1:

cout<<" Total days in january are 31 "<<endl;

break;

case 2:

cout<<" Total days in febrary are 28 "<<endl;

break;

case 3:

cout<<" Total days in march are 31 "<<endl;

break;

case 4:

cout<<" Total days in april are 30 "<<endl;

break;

case 5:

cout<<" Total days in may are 31 "<<endl;

break;

case 6:

cout<<" Total days in june are 31 "<<endl;

break;

case 7:

cout<<" Total days in july are 31 "<<endl;

break;

case 8:

cout<<" Total days in august are 31 "<<endl;

break;

case 9:

cout<<" Total days in septanber are 30 "<<endl;

break;

case 10:

cout<<" Total days in octobar are 31 "<<endl;


break;

case 11:

cout<<" Total days in november are 30 "<<endl;

break;

case 12:

cout<<" Total days in december are 31 "<<endl;

break;

case 13:

exit(0);

dafult:

cout<<" Invalid input "<<endl;

getch();

clrscr();

getch();

//Q#14 R.BT15012 N.B.Sidra S.A.M

#include<iostream.h>

#include<conio.h>

#include<math.h>

#include<stdlib.h>

void main()
{

while(1)

clrscr();

int choice,n;

cout<<endl;

cout<<" SCIENTIFIC CALCULATOR "<<endl;

cout<<endl;

cout<<" MAID BY SIDRA BASHIR "<<endl;

cout<<endl;

cout<<" ************************************* "<<endl;

cout<<endl;

cout<<" Enter 1 for on : "<<endl;

cout<<" Enter 2 for off : "<<endl;

cin>> choice;

clrscr();

cout<<endl<<endl;

cout<<" Press 1 for addition = "<<endl;

cout<<" Press 2 for subraction = "<<endl;

cout<<" Press 3 for multiplication = "<<endl;

cout<<" Press 4 for division = "<<endl;

cout<<" Press 5 for square = "<<endl;

cout<<" Press 6 for cube = "<<endl;

cout<<" Press 7 for square root = "<<endl;

cout<<" Press 8 for cosin = "<<endl;

cout<<" Press 9 for sin = "<<endl;

cout<<" Press 10 for tan = "<<endl;

cout<<" Press 11 for cosec = "<<endl;


cout<<" Press 12 for sec = "<<endl;

cout<<" Press 13 for cot = "<<endl;

cout<<" Press 14 for common log = "<<endl;

cout<<" Press 15 for antilog = "<<endl;

cout<<" Press 16 for cube root = "<<endl;

cout<<" Press 17 for odd or even number = "<<endl;

cout<<" Press 18 for exit = "<<endl;

cin>> n;

switch(n)

case 1:

int a,b,c;

cout<<endl;

cout<<" YOU ARE USING ADDITION FUNCTION OF THE CALCULATOR "<<endl;

cout<<endl;

cout<<" ******************************************************** "<<endl;

cout<<endl;

cout<<" Enter first value = ";

cin>> a;

cout<<" Enter second value = ";

cin>> b;

c= a+b;

cout<<" Sum is = "<<c<<endl;

break;

case 2:

cout<<" YOU ARE USING SUBTRACTION FUNCTION OF CALCULATOR "<<endl;


cout<<endl;

cout<<" ******************************************************** "<<endl;

cout<<endl;

int x,y,z;

cout<<" Enter first value = ";

cin>> x;

cout<<" Enter second value = ";

cin>> y;

z=x-y;

cout<<" Subtraction result is = "<<z<<endl;

break;

case 3:

cout<<" YOU ARE USING MULTIPLICATION FUNCTION OF CALCULATOR "<<endl;

cout<<endl;

cout<<" ********************************************************** "<<endl;

cout<<endl;

int p,q,r;

cout<<" Enter first value = ";

cin>> p;

cout<<" Enter second value = ";

cin>> q;

r=p*q;

cout<<" Result is = "<<r<<endl;

break;

case 4:

cout<<" YOU ARE USING DIVISION FUNCTION OF CALCULATOR "<<endl;

cout<<endl;
cout<<" ********************************************************** "<<endl;

cout<<endl;

int n,m,o;

cout<<" Enter first value = ";

cin>> n;

cout<<" Enter second value = ";

cin>> m;

o=n/m;

cout<<" Result is = "<<o<<endl;

break;

case 5:

cout<<" YOU ARE USING SQUARE FUNCTION OF CALCULATOR "<<endl;

cout<<endl;

cout<<" ********************************************************** "<<endl;

cout<<endl;

int v,w;

cout<<" Enter a value = ";

cin>> v;

w=pow(v,2);

cout<<" Result is = "<<w<<endl;

break;

case 6:

cout<<" YOU ARE USING CUBE FUNCTION OF CALCULATOR "<<endl;

cout<<endl;

cout<<" ********************************************************** "<<endl;

cout<<endl;

int e,h;

cout<<" Enter a value = ";


cin>> e;

h=pow(e,3);

cout<<" Result is = "<<h<<endl;

break;

case 7:

cout<<" YOU ARE USING square root FUNCTION OF CALCULATOR "<<endl;

cout<<endl;

cout<<" ********************************************************** "<<endl;

cout<<endl;

int k,s;

cout<<" Enter a value = ";

cin>> k;

s=sqrt(k);

cout<<" Result is = "<<s<<endl;

break;

case 8:

cout<<" YOU ARE USING COSINE FUNCTION OF CALCULATOR "<<endl;

cout<<endl;

cout<<" ********************************************************** "<<endl;

cout<<endl;

float d,f;

cout<<" Enter a value = ";

cin>> d;

f=cos(d);

cout<<" Result is = "<<f<<endl;

break;

case 9:

cout<<" YOU ARE USING sin FUNCTION OF CALCULATOR "<<endl;

cout<<endl;
cout<<" ********************************************************** "<<endl;

cout<<endl;

float Z,i;

cout<<" Enter a value = ";

cin>> z;

i=sin(Z);

cout<<" Result is = "<<i<<endl;

break;

case 10:

cout<<" YOU ARE USING TAN FUNCTION OF CALCULATOR "<<endl;

cout<<endl;

cout<<" ********************************************************** "<<endl;

cout<<endl;

float g,t;

cout<<" Enter a value = ";

cin>> g;

t=tan(g);

cout<<" Result is = "<<t<<endl;

break;

case 11:

cout<<" YOU ARE USING COSEC FUNCTION OF CALCULATOR "<<endl;

cout<<endl;

cout<<" ********************************************************** "<<endl;

cout<<endl;

float l,U;

cout<<" Enter a value = ";

cin>> l;

U=1/sin(l);

cout<<" Result is = "<<U<<endl;


break;

case 12:

cout<<" YOU ARE USING SEC FUNCTION OF CALCULATOR "<<endl;

cout<<endl;

cout<<" ********************************************************** "<<endl;

cout<<endl;

float j,u;

cout<<" Enter a value = ";

cin>> j;

u=1/cos(j);

cout<<" Result is = "<<u<<endl;

break;

case 13:

cout<<" YOU ARE USING COT FUNCTION OF CALCULATOR "<<endl;

cout<<endl;

cout<<" ********************************************************** "<<endl;

cout<<endl;

float A,B;

cout<<" Enter a value = ";

cin>> A;

B=1/tan(A);

cout<<" Result is = "<<B<<endl;

break;

case 14:

cout<<" YOU ARE USING COMMON LOG FUNCTION OF CALCULATOR "<<endl;

cout<<endl;
cout<<" ********************************************************** "<<endl;

cout<<endl;

float C,D;

cout<<" Enter a value = ";

cin>> C;

D=log(C);

cout<<" Result is = "<<D<<endl;

break;

case 15:

cout<<" YOU ARE USING ANTI LOG FUNCTION OF CALCULATOR "<<endl;

cout<<endl;

cout<<" ********************************************************** "<<endl;

cout<<endl;

float N,M;

cout<<" Enter a value = ";

cin>> N;

M=1/log(N);

cout<<" Result is = "<<M<<endl;

break;

case 16:

cout<<" YOU ARE USING CUBE ROOT FUNCTION OF CALCULATOR "<<endl;

cout<<endl;

cout<<" ********************************************************** "<<endl;

cout<<endl;

float G,K;

cout<<" Enter a value = ";

cin>> K;

G=pow(K,1/3);
cout<<" Result is = "<<G<<endl;

break;

case 17:

cout<<endl;

cout<<" YOU ARE USING ODD FUNCTION OF CALCULATOR "<<endl;

cout<<endl;

cout<<" *********************************************** "<<endl;

cout<<endl;

int V;

cout<<" Enter a number = ";

cin>> V;

if(V%2==0)

cout<<" Number is even = "<<V<<endl;

else

cout<<" Number is odd = "<<V<<endl;

break;

cout<<endl;

case 18:

exit(0);

dafult:

cout<<" Invalid input : "<<endl;}

getch();

clrscr();}

getch();

}
//Q#15 R.BT15012 N.B.Sidra S.A.M

;;;;;;;HEADER FILES;;;;;;;;

*iostream.h

* conio.h

*math.h

*iomanip.h

*stdlib.h

*stdio.h

*complex.h

*new.h

*cmath.h

*limits.h

*string.h

*stream.h

*numeric.h

*fstream.h

*atomic.h

*algorithm.h

*mem.h
*cstdio.h

*ctype.h

//Q#16 R.BT15012 N.B.Sidra S.A.M

BUILT _IN FUNCTIONS

******************************

"Buil_in functions are the ready made functions that are available as a part of language"

List of built_in functions:

'clrscr()'

The word clrscr stands for clear screen. The function is used to clear the screen. When this function is executed in a program cursor clear
the screen and apears on the top left corner. It can be used by including conio.h file in program.

'clreol()'

The word clreol stands for clear end of line. The function is used to clear current line from current cursor position to the end of line. It is
include in conio.h header file.

'getch()'

The word getch stands for get charcter.The function is used to get single inputn from user. It is include in conio.h header file.

'getche()'

It is stands for get character. It is used to get single character input. It displays character on screen. It is include in conio.h header file. It
displays character on screen.

'kbhit()'

The word kbhit stands for keyboard hit. The function is used to check if the user hit the keyboard or not.It is include in conio.h header file.

'gotoxy()'

The gotoxy() function is used to move the cursor to a specified location on the screen. It is include in conio.h header file.

'getchar()'

The word getchar stands for get character. It is similar to getch function in conio.h header file. The getchar() function is include in stdio.h
file.

'putchar()'

The word putchar stands for put character. The function is used to display single character on screen. It is include in stdio.h header file.

'gets()'

The word gets stand for get string . The function is used to input a string value from key board. It is include in stdio.h header file.
'puts()'

The word puts stand for put string. The function is used to display a string value on screen. It is include in stdio.h header file.

'abs()'

The abs() function is used to find the absolute value of an integer. It is include in math.h header file.

'fabs()'

The fabs() function is used to fined the absolute value of a flaoitng point number. It is include in math.h header file.

'ceil()'

The ceil() function rounds a flaot or double value to the next integer and returns it. It is include in math.h header file.

'floor()'

The floor() function rounds a float or double value to an integer and returns it. It is include in math.h header file.

'cos()'

The cos() function is used to fined the trigonometric cosine of the specified angle.It is include in math.h header file.

'sin()'

The sin() function is used to fined the trigonometric sin of the angle. It is include in math.h header file.

'tan()'

The tan() function is used to find the trigonometric tangent of the specified angle. It is include in math.h header file.

'log()'

The log() function is used to fined the natural log of a given floating point value. It is include in math.h file.

'lod10()'

The log10() function is used to find the natural log of a given floating point value. It is include in math.h file.

'fmod()'

The fmod() function is used to find remainder by divising two floating point values. It is include in math.h file.

'pow()'

The pow() function is used to find the result of one intager raised to the power of second integer. It is include in math.h header file.

'sqrt()'

The sqrt() function is used to calculate the squre root of a floating point number. It is include in math.h file.

'memchr()'

The memchr() function is used to search a byte with a particular value in buffer. It is include in string.h header file.

'strchr()'
The strchr function is used to find the first occurrence of a character in string and returns a pointer to this character. It is include in
string.h file.

'stpcpy()'

The stpcpy() function copies one string to other. It is include in string.h header file.

'strupr()'

The strupr() function converts all charactor of a string to upper case. It is include in string.h header file.

'strdup()'

The strdup() function duplicates a string in a newly created space. It is include in string.h header file.

'strrev()'

The strxfrm() function revereses all charactor in a string except the null characters. It is include in string.h header file.

'strset()'

The strset() function sers all charactors in a string to the specified except the null charactors. It is include in string.h header file.

'strwr()'

The strlwr() function converts all charactors of a string to lower case. It is include in string.h header file.

**********************************

//Q#17 R.BT15012 N.B.Sidra S.A.M

******FIND OUT ERRORS*******

if(x!=0)

a=a/x;

switch(number%2)

case 0:

Cout<<"The number "<<number<''is divisible by 3''<<endl;

Default:

cout<<''The number ''<<number <<''is divisible by 3''<<endl;

}
****ERRORS*****

.cout command always started with capital latter

.run_time error

.D of default always written in lower case

.In first cout statement one angle brace is massing

.Undifind symbol number

.a is assingned a value that is further not used

//Q#18 R.BT15012 N.B.Sidra S.A.M

output of the code

int p,q,r;

p=10;

q=3;

r=-2;

if((p+q)<14 && (r<q<-3))

cout<<r;

else

cout<<p;

****OUTPUT*****

10

//Q#19 R.BT15012 N.B.Sidra S.A.M

*******MANIPULATORS*******

"Manipulators are built_in functions

which are used to give output in diff_


erent styles."

These are also used to control output for mating.

Some important manipulators are:

.endl()

.setprecision()

.setfill()

.showpoint()

.fixed()

.sizeof()

.setw()

***********************

~endl()

The word endl() stands for endl of line. The endl manipulator is used to move cursor to the beginning of next line. This manipulator can
be use by including iostream.h file in program.

,,Example

cout<<"Hello"<<endl<<"World";

The above line will displays

Hello

World

The above example first display Hello then endl

operator insert new line and displays World.

~setw()

The word setw() stands for set width. The setw manipulator is used to display the value of an expression inspecified format. The setw
manipulator is a part of iomanip.h file.

syntax:

setw(n)

;;Example

a=33 b=75
cout<<setw(4)<<a<<setw(5)<<b<<setw(4)<<"Hiii";

In the above example the output will displays

33 75 Hiii

#include<iostream.h>

#include<conio.h>

#include<iomanip.h>

void main()

int a=33;

clrscr();

cout<<setw(4)<<a<<endl;

getch();

OUTPUT:

33

~setprecision()

It shows the number of decimal

digit. It can be used by including iostream.h header file in program.

Syntax::

setprecision(n)

;;Example

#include<iostream.h>

#include<conio.h>

#include<iomanip.h>

void main()

{
int a;

a=10;

clrscr();

cout<<setprecision(5)<<a<<endl;

getch();

~sizeof()

The sizeof() manipulator is used to find the size of data value. It gives the number of bytes occupied by that value. This is used by
including iostream.h header file.

;;Example

sizeof(10)

sizeof(n)

sizeof("Pakistan")

~fixed()

The fixed manipulator is used to further control the output of floating point numbers. It displays the floating point numbers in a fixed
decimal format. It is used by including iomanip.h file.

~showpoint()

The showpoint() manipulator is used to displays the decimal part even if the decimal part is zero. It is include in iomanip.h file.

;;Example

#include<iostream.h>

#include<conio.h>

#include<iomanip.h>

void main()

int a;

a=5.8970;

clrscr();

cout<<shopoint(a);

getch();
}

OUTPUT

8970

You might also like