Professional Documents
Culture Documents
“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();
cin>> r;
area=3.14*r*r;
circumference=2*3.14*r*r;
getch();
}
//Q#2 R.BT15012 N.B.Sidra S.A.M
#include<iostream.h>
#include<conio.h>
void main()
int inches,centimeter,height;
clrscr();
cin>> inches;
centimeter=2.54*height;
getch();
#include<iostream.h>
#include<conio.h>
void main()
int feet,inches,meter,height;
clrscr();
cin>> height;
feet=inches/12;
cout<<" Height in feet is = "<<feet<<endl;
meter=feet/39;
getch();
#include<iostream.h>
#include<conio.h>
void main()
int s,vi,a,t;
clrscr();
cin>> vi;
cin>> t;
cin>> a;
s=vi*t+1/2*a*t*t;
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();
cin>> salaries;
cin>> rent_of_building;
cin>> electricity_charges;
cin>> carriage;
cin>> purchases;
cin>> interest_paid;
cin>> commission_paid;
cin>> dearness_allowance;
cin>> packing_charges;
cin>> sales;
cin>> commission_received;
cin>> interest_received;
cin>> discount_received;
cin>> rent_received;
total_expenses=salaries+rent_of_building+electricity_charges+carriage+purchases+interest_paid+commission_paid+dearness_allowance+packi
ng_charges;
cout<<endl;
total_revenues=sales+commission_received+interest_received+discount_received+rent_received;
cout<<endl;
loss=total_expenses-total_revenues;
profit=total_revenues-total_expenses;
if(total_expenses>total_revenues)
else if(total_expenses<total_revenues)
getch();
#include<iostream.h>
#include<conio.h>
void main()
clrscr();
cout<<endl<<endl;
cout<<"******************************************************"<<endl;
float rate,year,loan,interest,month,amount;
cin>>loan;
cin>>rate;
cin>>month;
year=month/12;
interest=loan*year*(rate/100);
amount=loan+interest;
cout<<endl<<endl;
clrscr();
cout<<"______________________________________________________"<<endl;
cout<<endl<<endl<<endl;
cout<<"*******************************************************";
getch();
#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();
#include<iostream.h>
#include<conio.h>
void main()
clrscr();
long temprature,celsius,fahrenheit;
cout<<endl;
cin>> temprature;
celsius=(fahrenheit-32)*5/9;
getch();
}
#include<iostream.h>
#include<conio.h>
void main()
float tamprature,fahrenheit,celsius;
clrscr();
cout<<endl;
cin>> tamprature;
fahrenheit=celsius*9.0/5.0+32;
getch();
#include<iostream.h>
#include<conio.h>
void main()
{
int a,b;
clrscr();
cin>> a;
cin>>b;
if(a>b||b>a)
else
getch();
#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;
cin>> a;
cout<<" Enter second number = ";
cin>> b;
if(a*a==b)
else
getch();
#include<iostream.h>
#include<conio.h>
void main()
int a,b,c,d;
clrscr();
cout<<endl;
cout<<endl;
cout<<endl;
cin>> a;
cin>> c;
cin>> d;
cout<<endl<<endl;
else
getch();
#include<iostream.h>
#include<conio.h>
void main()
int a,b,c,d;
clrscr();
cout<<endl;
cout<<endl;
cout<<endl;
cin>> a;
cin>> b;
cin>> c;
cin>> d;
cout<<endl<<endl;
else
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<<endl;
cout<<endl;
cin>> n;
if(n>0)
else if(n<0)
else
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<<endl;
cout<<endl;
cin>> n;
if(n%2==0)
else
#include<iostream.h>
#include<conio.h>
void main()
double salary,bonous,net_salary,grade;
clrscr();
cout<<endl;
cout<<endl;
cout<<endl;
cin>> salary;
cin>> grade;
if(grade>=19)
bonous=salary*70/100;
else if(grade>=16)
bonous=salary*40/100;
else
bonous=0;
net_salary=bonous+salary;
#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<<endl;
cout<<endl;
cin>> english;
cin>> urdu;
cin>> math;
cin>> I_study;
cin>> P_study;
cin>> bio;
cin>> chemistry;
if(english>=80)
else if(english>=70)
else if(english>=60)
else if(english>=50)
else if(english>=45)
else if(english>=40)
else if(english>=33)
else
cout<<endl<<endl;
if(urdu>=80)
else if(urdu>=70)
else if(urdu>=60)
else if(urdu>=50)
cout<<" Grade is C : "<<endl;
else if(urdu>=45)
else if(urdu>=40)
else if(urdu>=33)
else
cout<<endl<<endl;
if(math>=80)
else if(math>=70)
else if(math>=60)
else if(math>=50)
else if(math>=45)
else if(math>=40)
else if(math>=33)
else
cout<<endl<<endl;
if(I_study>=80)
else if(I_study>=60)
else if(I_study>=50)
else if(I_study>=45)
else if(I_study>=40)
else if(I_study>=33)
else
cout<<endl<<endl;
if(P_study>=80)
else if(P_study>=70)
else if(P_study>=60)
else if(P_study>=50)
else if(P_study>=45)
else if(P_study>=40)
else if(P_study>=33)
cout<<endl<<endl;
if(physics>=80)
else if(physics>=70)
else if(physics>=60)
else if(physics>=50)
else if(physics>=45)
else if(physics>=40)
else if(physics>=33)
else
cout<<endl<<endl;
if(bio>=80)
else if(bio>=70)
else if(bio>=60)
else if(bio>=50)
else if(bio>=45)
cout<<" Grade is D : "<<endl;
else if(bio>=40)
else if(bio>=33)
else
cout<<endl<<endl;
if(chemistry>=80)
else if(chemistry>=70)
else if(chemistry>=60)
else if(chemistry>=50)
else if(chemistry>=45)
else if(chemistry>=40)
else if(chemistry>=33)
else
cout<<endl<<endl;
total=english+bio+physics+chemistry+math+I_study+P_study+urdu;
average=total/8*100;
cout<<endl;
if(total>=80)
else if(total>=70)
else if(total>=60)
else if(total>=50)
else if(total>=45)
else if(total>=40)
else if(total>=33)
else
getch();
}
//Q#9(9) R.BT15012 N.B.SIDRA S.A.M
#include<iostream.h>
#include<conio.h>
void main()
char name[10];
clrscr();
cout<<endl<<endl;
cout<<endl;
cout<<endl;
cin>> name;
cin>> roll_num;
cout<<endl<<endl;
cout<<endl;
cout<<endl;
cout<<endl;
if(calculus>=85){
else if(calculus>=80){
else if(calculus>=75){
else if(calculus>=70){
else if(calculus>=65){
else if(calculus>=61){
else if(calculus>=58){
else if(calculus>=55){
else if(calculus>=50){
else
cout<<endl<<endl;
if(calculus>=85){
cal_points=4.00;
cal_points=3.70;
else if(calculus>=75){
cal_points=3.30;
else if(calculus>=70){
cal_points=3.00;
else if(calculus>=65){
cal_points=2.70;
else if(calculus>=61){
cal_points=2.30;
else if(calculus>=58){
cal_points=2.00;
else if(calculus>=55){
cal_points=1.70;
else if(calculus>=50){
cal_points=1.00;
else{
cal_points=0.00;
cout<<endl<<endl;
cout<<" WRITING WORKSHOP "<<endl;
cout<<endl;
cout<<endl;
cin>> workshop ;
cout<<endl;
if(workshop>=85)
else if(workshop>=80)
else if(workshop>=75)
else if(workshop>=70)
else if(workshop>=65)
else if(workshop>=61)
else if(workshop>=58)
else if(workshop>=55)
else if(workshop>=50)
else
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<<endl;
cin>> programing ;
cout<<endl;
if(programing>=85)
else if(programing>=80)
else if(programing>=75)
else if(programing>=70)
else if(programing>=65)
else if(programing>=61)
else if(programing>=58)
else if(programing>=55)
else if(programing>=50)
else
}
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<<endl;
cout<<" ******************************** "<<endl;
cout<<endl;
cin>> com ;
cout<<endl;
if(com>=85)
else if(com>=80)
else if(com>=75)
else if(com>=70)
else if(com>=65)
else if(com>=61)
else if(com>=58)
else if(com>=55)
else if(com>=50)
else
}
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<<endl;
cin>> e_m ;
cout<<endl;
if(e_m>=85)
else if(e_m>=80)
else if(e_m>=75)
else if(e_m>=70)
else if(e_m>=65)
else if(e_m>=61)
else if(e_m>=58){
else if(e_m>=55)
else if(e_m>=50)
else
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;
GPA=total/5;
cout<<endl<<endl;
clrscr();
cout<<" GPA is = "<<GPA<<endl;
cout<<endl;
getch();
#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<<"*********************************************************"<<endl;
cout<<endl<<endl<<endl;
cin>>name;
cin>>city;
cin>>grade;
cin>>salary;
cin>>ac;
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<<endl;
if(tt_salary>=7000000)
tax=tt_salary*30/100;
else if(tt_salary>=4000000)
tax=tt_salary*27.5/100;
tax=tt_salary*25/100;
tax=tt_salary*22.5/100;
tax=tt_salary*20/100;
tax=tt_salary*17.5/100;
tax=tt_salary*15/100;
tax=tt_salary*12.5/100;
tax=tt_salary*10/100;
tax=tt_salary*5/100;
tax=tt_salary*2/100;
else
tax=0;
n_salary=tt_salary-tax;
getch();
}
//Q#11 R.BT15012 N.B.SIDRA S.A.M
#include<iostream.h>
#include<conio.h>
void main()
int n;
clrscr();
cin>> n;
switch(n)
case 1:
break;
case 2:
break;
case 3:
break;
case 4:
break;
case 5:
break;
case 6:
break;
case 7:
break;
dafult:
getch();
#include<iostream.h>
#include<conio.h>
#include<stdlib.h>
void main()
while(1)
clrscr();
int choice;
cout<<endl<<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:
break;
case 2:
break;
case 3:
break;
case 4:
break;
case 5:
break;
case 6:
break;
case 7:
break;
case 8:
break;
case 9:
cout<<" THIS IS SEPTEMBER : "<<endl;
break;
case 10:
break;
case 11:
break;
case 12:
case 13:
exit(0);
dafult:
getch();
getch();
clrscr();
getch();
#include<iostream.h>
#include<conio.h>
#include<stdlib.h>
void main()
while(1)
int choice;
clrscr();
cout<<endl<<endl;
cin>> choice;
switch(choice)
{
case 1:
break;
case 2:
break;
case 3:
break;
case 4:
break;
case 5:
break;
case 6:
break;
case 7:
break;
case 8:
break;
case 9:
break;
case 10:
case 11:
break;
case 12:
break;
case 13:
exit(0);
dafult:
getch();
clrscr();
getch();
#include<iostream.h>
#include<conio.h>
#include<math.h>
#include<stdlib.h>
void main()
{
while(1)
clrscr();
int choice,n;
cout<<endl;
cout<<endl;
cout<<endl;
cout<<endl;
cin>> choice;
clrscr();
cout<<endl<<endl;
cin>> n;
switch(n)
case 1:
int a,b,c;
cout<<endl;
cout<<endl;
cout<<endl;
cin>> a;
cin>> b;
c= a+b;
break;
case 2:
cout<<endl;
int x,y,z;
cin>> x;
cin>> y;
z=x-y;
break;
case 3:
cout<<endl;
cout<<endl;
int p,q,r;
cin>> p;
cin>> q;
r=p*q;
break;
case 4:
cout<<endl;
cout<<" ********************************************************** "<<endl;
cout<<endl;
int n,m,o;
cin>> n;
cin>> m;
o=n/m;
break;
case 5:
cout<<endl;
cout<<endl;
int v,w;
cin>> v;
w=pow(v,2);
break;
case 6:
cout<<endl;
cout<<endl;
int e,h;
h=pow(e,3);
break;
case 7:
cout<<endl;
cout<<endl;
int k,s;
cin>> k;
s=sqrt(k);
break;
case 8:
cout<<endl;
cout<<endl;
float d,f;
cin>> d;
f=cos(d);
break;
case 9:
cout<<endl;
cout<<" ********************************************************** "<<endl;
cout<<endl;
float Z,i;
cin>> z;
i=sin(Z);
break;
case 10:
cout<<endl;
cout<<endl;
float g,t;
cin>> g;
t=tan(g);
break;
case 11:
cout<<endl;
cout<<endl;
float l,U;
cin>> l;
U=1/sin(l);
case 12:
cout<<endl;
cout<<endl;
float j,u;
cin>> j;
u=1/cos(j);
break;
case 13:
cout<<endl;
cout<<endl;
float A,B;
cin>> A;
B=1/tan(A);
break;
case 14:
cout<<endl;
cout<<" ********************************************************** "<<endl;
cout<<endl;
float C,D;
cin>> C;
D=log(C);
break;
case 15:
cout<<endl;
cout<<endl;
float N,M;
cin>> N;
M=1/log(N);
break;
case 16:
cout<<endl;
cout<<endl;
float G,K;
cin>> K;
G=pow(K,1/3);
cout<<" Result is = "<<G<<endl;
break;
case 17:
cout<<endl;
cout<<endl;
cout<<endl;
int V;
cin>> V;
if(V%2==0)
else
break;
cout<<endl;
case 18:
exit(0);
dafult:
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
******************************
"Buil_in functions are the ready made functions that are available as a part of language"
'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.
**********************************
if(x!=0)
a=a/x;
switch(number%2)
case 0:
Default:
}
****ERRORS*****
.run_time error
int p,q,r;
p=10;
q=3;
r=-2;
cout<<r;
else
cout<<p;
****OUTPUT*****
10
*******MANIPULATORS*******
.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";
Hello
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";
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()
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