Professional Documents
Culture Documents
All Week Hard Coopy Word Program
All Week Hard Coopy Word Program
All Week Hard Coopy Word Program
Management system
Submitted by:
Atta ul mohamin,
2020-cs-43
Submitted to:
:
Dr . Awais Hassan
For fulfillment of
Week 1
(calculator to finding age)
#include<iostream>
using namespace std;
int main(){
cout<<"********************************"<<endl;
cout<< "calculate age"<<endl;
cout<<"********************************"<<endl;
cout<<endl;
int a,b,c,d;
cin>>a;
cin>>b;
c=a+10;
d=b+10;
cout<<c<<endl;
cout<<d<<endl;
}
(Kg to gram)
#include<iostream>
using namespace std;
int main(){
cout<<"****************************"<<endl;
cout<<"unit converter value"<<endl;
cout<<"****************************"<<endl;
cout<<endl;
}
(Area of rectangle)
#include<iostream>
using namespace std;
int main(){
cout<<"********************************"<<endl;
cout<< "area of rectangle"<<endl;
cout<<"********************************"<<endl;
cout<<endl;
int a,b,c;
cin>>b;
cin>>c;
a=b*c;
int main(){
cout<<"****************************"<<endl;
cout<<"FIBONACI"<<endl;
cout<<"****************************"<<endl;
cout<<endl;
int m,l,c,d,e,f,g,h;
cin>>m;
cin>>l;
c=m+l;
d=l+c;
e=c+d;
f=d+e;
g=e+f;
h=f+g;
cout<<c<<endl;
cout<<d<<endl;
cout<<e<<endl;
cout<<f<<endl;
cout<<g<<endl;
cout<<h<<endl;
}
(Area diameter circumferance of CIRCLE)
#include<iostream>
using namespace std;
int main ()
{
cout<<"**************"<<endl;
cout<<"calculate area ,diameter,circumferance of circle"<<endl;
cout<<"***************"<<endl;
cout<<endl;
float d,r,c,a,pi=3.14285;
d=2*r;
cout<<"diameter is"<<d<<endl;
cout<<endl;
a=pi*r*r;
cout<<"area i s: "<<a<<endl;
cout<<endl;
c=2*pi*r;
cout<<"\ncircumferance is"<<c<<endl;
}
( Aggregate of subjects)
#include<iostream>
using namespace std;
int main(){
cout<<"************************"<<endl;
cout<<"to find average marks of four subject"<<endl;
cout<<"*************************"<<endl;
cout<<endl;
float p,m,c,s;
cin>>p;
cin>>m;
cin>>c;
cin>>s;
float a;
a=(p+m+c+s)/4;
#include<iostream>
using namespace std;
int main(){
cout<<"********************************"<<endl;
cout<< "celsius to faranhieght"<<endl;
cout<<"********************************"<<endl;
cout<<endl;
float f,c;
cin>>c;
f=c*1.8+32;
cout<<f<<endl;
}
int main(){
cout<<"****************************"<<endl;
cout<<"merit calculator"<<endl;
cout<<"****************************"<<endl;
cout<<endl;
float a,b,c;
cout<<"ENTER MATRIC MARKS"<<endl;
cin>>a;
cout<<"ENTER FSC MARKS"<<endl;
cin>>b;
cout<<"ENTER ECAT MARKS"<<endl;
cin>>c;
float X;
X=a*0.25+b*.45+c*.30;
cout<<"AGGRIGRATE IS: "<<X<<endl;
}
Week 1 End
Week 2
int x;
cout<<"put number."<<endl;
cin>>x;
if((x>40 && x<50)||(x>60 && x<70 )){
cout<<"the number is valid..";}
else
{
cout<<"invalid..";}
}
(Finding factorial)
#include<iostream>
using namespace std;
int main(){
int num;
cout<<"enter the number";
cin>>num;
a1=n*1;
a2=n*2;
a3=n*3;
a4=n*4;
a5=n*5;
cout<<a1<<endl;
cout<<a2<<endl;
cout<<a3<<endl;
cout<<a4<<endl;
cout<<a5<<endl;
b1=m*1;
b2=m*2;
b3=m*3;
b4=m*4;
b5=m*5;
cout<<b1<<endl;
cout<<b2<<endl;
cout<<b3<<endl;
cout<<b4<<endl;
cout<<b5<<endl;
int x;
x=a1+a2+a3+a4+a5+b1+b2+b3+b4+b5;
cout<<"sum is: "<<x<<endl;
}
#include<iostream>
using namespace std;
int main(){
int x;
cout<<"put number."<<endl;
cin>>x;
(ZODIAC SIGN)
#include<iostream>
using namespace std;
int main(){
int x;
cout<<"date of birth..";
cin>>x;
int y;
cout<<"month of year..";
cin>>y;
if(((x>=22)||(x<=20))&&((y==1)||(y==12))){
cout<<"star is capricon..";}
else if(((x>=21)||(x<=19))&&((y==1)||(y==2))){
cout<<"star is aquarus..";}
else if(((x>=20)||(x<=20))&&((y==2)||(y==3))){
cout<<"star pisces.";}
else if(((x>=21)||(x<=19))&&((y==3)||(y==4))){
cout<<"star is aries..";}
else if(((x>=20)||(x<=20))&&((y==4)||(y==5))){
cout<<"star is taurus..";}
else if(((x>=21)||(x<=21))&&((y==5)||(y==6))){
cout<<"star is gimni..";}
else if(((x>=22)||(x<=23))&&((y==6)||(y==7))){
cout<<"star is cancers..";}
else if(((x>=24)||(x<=23))&&((y==7)||(y==8))){
cout<<"star is leo..";}
else if(((x>=24)||(x<=22))&&((y==8)||(y==9))){
cout<<"star is virgo..";}
else if(((x>=23)||(x<=22))&&((y==9)||(y==10))){
cout<<"star is libra..";}
else if(((x>=23)||(x<=22))&&((y==10)||(y==11))){
cout<<"star is scorpio..";}
else if(((x>=23)||(x<=20))&&((y==11)||(y==12))){
cout<<"star is segetarius..";}
return 0;
int n1;
cout<<"enter first numb..";
cin>>n1;
int n2;
cout<<"enter second number";
cin>>n2;
int sum=0;
int n1;
cout<<"enter first numb..";
cin>>n1;
int n2;
cout<<"enter second number";
cin>>n2;
int a;
cout<<"enter the fibnoic series..";
cin>>a;
int n3;
n3=n1+n2;
n1=n2;
n2=n3;
cout<<n3<<endl;
}}
#include<iostream>
using namespace std;
int main(){
int d;
cout<< "enter the decimal no";
cin>>d;
int a;
int b;
int c;
int e;
( Week 2 END)
(Week 3)
(Start)
#include<iostream>
using namespace std;
int main(){
int x,a;
cin>>a;
cout<<"enter the no"<<endl;
while(a!=0){
x=a%2;
cout<<x<<endl;
a=a/2;
}
}
(DISCOUNT ON PURCHASING)
#include<iostream>
using namespace std;
int main(){
cout<<"discount offer"<<endl;
cout<<endl;
int numbooks;
cout<<"enter quantity ofbook"<<endl;
cin>>numbooks;
int total;
total=numbooks*100;
float payable;
if(total >=10){
payable=total-(0.1*total);}
else{payable=total;}
#include<iostream>
using namespace std;
int main(){
int n1;
cout<<"enter first numb..";
cin>>n1;
int n2;
cout<<"enter second number";
cin>>n2;
int sum=0;
( Lilly)
#include<iostream>
using namespace std;
int main(){
int age;
int money=0;
int wash;
int toy;
cout<<"enter age";
cin>>age;
cout<<"price o washing machine";
cin>>wash;
cout<<"toy price";
cin>>toy;
for(int x=1;x<=age;x++){
if(x%2==0){money=money+(x/2*10)-1;}
else{money=money+toy;}
}
if(money>=wash){cout<<"can buy"<<money<<endl;}
else{cout<<"cannot buy"<<money<<endl;}
return 0;
}
cout<<"enter year";
cin>> year;
int x,y;
for(x=1800;x<=year;x++)
{
y=x%2;if(y==0){money=money-12000;}
else{money=money-(12000+age*50);}
age=age+1;}
if(money>0){cout<<"money is greater"<<money<<endl;}
if(money<0){cout<<"money is lesser"<<money<<endl;}
return 0;
}
(MUSUM DISCOUNT )
#include <iostream>
using namespace std;
int main(){
int x;
cout<<"day is";
cin>>x;
int y;
cout<<"age of human";
cin>>y;
#include<iostream>
using namespace std;
int main(){
int num;
cout<<"enter the number";
cin>>num;
cout<<num<<"*"<<x<<"="<<num*x<<endl;
}
}
#include<stdlib.h>
#include<string.h>
#include<conio.h>
using namespace std;
int main(){
cout<<"*********************************************"<<endl;
cout<<"security management system"<<endl;
cout<<"*********************************************"<<endl;
string n1,n2,n3,n4;
string p1,p2,p3,p4;
string m1,m2,m3,m4;
string message1,message2,message3;
string sendto1,sendto2,sendto3;
string sender1,sender2,sender3;
int totalmessages=0;
string admin="ali";
string pas="12345";
int option=1;
int total=0;
string loginuser;
while(true){
system ("CLS");
cout<<"enter admin name"<<endl;
cin>>n1;
cout<<"enter pas code"<<endl;
cin>>p1;
while(option !=4){
system ("CLS");
cout<<"1. add new man record "<<endl;
cout<<"2. view all record "<<endl;
cout<<"3. change"<<endl;
cout<<"4. logout" <<endl;
getch();
if(option==2){cout<<"NAME\t"<<"PASWORD\t"<<endl;
cout<<n2<<"\t"<<p2<<"\t"<<endl;
cout<<n3<<"\t"<<p3<<"\t"<<endl;
cout<<n4<<"\t"<<p4<<"\t"<<endl;
getch();}
if(option==3){
string changename;
if(changename==n2){
string newpin;
cout<<"enter new pin"<<endl;
cin>>newpin;
p2=newpin;
cout<<"your pin has sucesfuly changed"<<endl;
}
else if(changename==n3){
string newpin;
cout<<"enter new pin"<<endl;
cin>>newpin;
p3=newpin;
cout<<"your pin has sucesfuly changed"<<endl;
}
else if(changename==n4){
string newpin;
cout<<"enter new pin"<<endl;
cin>>newpin;
p4=newpin;
cout<<"your pin has sucesfuly changed"<<endl;}
getch();
}
if(option==4){
}}
else{
//code for other users..
bool isvaliduser=false;
if (isvaliduser==false){
cout<<"invalid user"<<endl;}
if(isvaliduser){
system ("CLS");
int useroption=100;
while(useroption!=3){
cout<<"1. send msg"<<endl;
cout<<"2. view msg "<<endl;
cout<<"3. logout "<<endl;
cout<<"enter option"<<endl;
cin>>useroption;
if(useroption==1){
//send message code here
string receivername,sendmessage;
if(totalmessages==1){
message1=sendmessage;
sendto1=receivername;
sender1=loginuser;}
if(totalmessages==2){
message2=sendmessage;
sendto2=receivername;
sender2=loginuser;}
if(totalmessages==3){
message3=sendmessage;
sendto3=receivername;
sender3=loginuser;}
if(totalmessages==3)
{totalmessages=0;}
}
if(useroption==2){
//show messages.
cout<<"Login User..."<<loginuser;
if(loginuser==sendto1){
cout<<sender1<<"send the message"<<endl;
cout<<message1;
cout<<endl;}
if(loginuser==sendto2){
cout<<sender2<<"send the message"<<endl;
cout<<message2;
cout<<endl;}
if(loginuser==sendto3){
cout<<sender3<<"send the message"<<endl;
cout<<message3;
cout<<endl;
}
cout<<"press any word to contiue"<<endl;
getch();
}
if(useroption==3){
cout<<"lodout"<<endl;}
}
}}}}
cout<<"*********************************************"<<endl;
cout<<"university admission management system"<<endl;
cout<<"*********************************************"<<endl;
string name1,name2,name3;
float matric1,fsc1,ecat1=0,matric2=0,matric3,fsc2,fsc3,ecat2=0,ecat3;
float x,y,z;
int option;
int total=0;
while(option !=4){
system("CLS");
cout<<"1. add new student record "<<endl;
cout<<"2. view all record "<<endl;
cout<<"3. print the record in accending order"<<endl;
cout<<"4. exist"<<endl;
cout<<"enter option ";
cin>>option;
cout<<option;
if(option==1){if(total==0){
cout<<"name"<<endl;
cin>>name1;
cout<<"mtric"<<endl;
cin>>matric1;
cout<<"fsc"<<endl;
cin>>fsc1;
cout<<"entry"<<endl;
cin>>ecat1;
x=((matric1/1100)*0.25)+((fsc1/1100)*0.45)+((ecat1/400)*0.30);
x=x*100;
cout<<"percent1 "<<x<<endl;
total=total+1;
getch();
}
else if(total==1){
cout<<"name"<<endl;
cin>>name2;
cout<<"mtric"<<endl;
cin>>matric2;
cout<<"fsc"<<endl;
cin>>fsc2;
cout<<"entry"<<endl;
cin>>ecat2;
y=((matric2/1100)*0.25)+((fsc2/1100)*0.45)+((ecat2/400)*0.30);
y=y*100;
cout<<"percent2 "<<y<<endl;
total=total+1;
getch();
}
else if(total==2){
cout<<"name"<<endl;
cin>>name3;
cout<<"mtric"<<endl;
cin>>matric3;
cout<<"fsc"<<endl;
cin>>fsc3;
cout<<"entry"<<endl;
cin>>ecat3;
z=((matric3/1100)*0.25)+((fsc3/1100)*0.45)+((ecat3/400)*0.30);
z=z*100;
cout<<"percent3 "<<z<<endl;
total=total+1;
getch();
}
if(total>=3)
{total=1;}
}
cout<<option;
if(y>z){cout<<name2<<"\t"<<matric2<<"\t"<<fsc2<<"\t"<<ecat2<<"\t"<<y<<"\t"<<endl;
cout<<name3<<"\t"<<matric3<<"\t"<<fsc3<<"\t"<<ecat3<<"\t"<<z<<"\t"<<endl;}
if(z>y){ cout<<name3<<"\t"<<matric3<<"\t"<<fsc3<<"\t"<<ecat3<<"\t"<<z<<"\t"<<endl;
cout<<name2<<"\t"<<matric2<<"\t"<<fsc2<<"\t"<<ecat2<<"\t"<<y<<"\t"<<endl;}}
getch();
}
}
}
( Week 3 end)
Start
(Week 4 )
#include<iostream>
using namespace std;
int main(){
int n1;
cout<<"enter first numb..";
cin>>n1;
int n2;
cout<<"enter second number";
cin>>n2;
int sum=0;
cout<<"*********************************************"<<endl;
cout<<"even no"<<endl;
cout<<"*********************************************"<<endl;
int x,y;
while(true){
cout<<"enter decimal no"<<endl;
cin>>x;
y=x%2;
if(y==0){
cout<<"the no is even"<<y<<endl;}
#include<iostream>
using namespace std;
int main(){
int n1,n2;
cout<<"enter first no";
cin>>n1;
cout<<"enter second no";
cin>>n2;
int a;
cout<<"enter multiple of no";
cin>>a;
cout<<"*********************************************"<<endl;
cout<<"security management system by ray"<<endl;
cout<<"*********************************************"<<endl;
string admin="ali";
string admpin="12345";
string usernam,userpin;
int admoption=0;
int totaluser=0;
string messages[100];
int totalmessages=0;
string sender[10];
string receiver[10];
int idx=0;
string name[10];
string pin[10];
int useroption=0;
while(true){
system("CLS");
while(admoption !=4){
system ("CLS");
cout<<"1. add new man record "<<endl;
cout<<"2. view all record "<<endl;
cout<<"3. change"<<endl;
cout<<"4. log out" <<endl;
getch();
}
}
else{ //other user code herre/..
string loginuser;
bool isuserfound=false;
for(int idx=0;idx<totaluser;idx++){
if(name[idx]==usernam && pin[idx]==userpin){
loginuser=usernam;
isuserfound=true;}}
if(isuserfound){
while(useroption!=3){
system("CLS");
cout<<"enter option"<<endl;
cin>>useroption;
if(useroption==1){
string message;
string greceiver;
cout<<"write ur messages here"<<endl;
cin>>message;
cout<<"enter name of reciever"<<endl;
cin>>greceiver;
messages[totalmessages]=message;
receiver[totalmessages]=greceiver;
sender[totalmessages]=loginuser;
totalmessages=totalmessages+1;
}
if(useroption==2){
for(int idx=0;idx<totalmessages;idx++){
if(receiver[idx]==loginuser){
cout<<sender[idx];
cout<<"send u the message"<<endl;
cout<<messages[idx];
}}
getch();}
}}
}}}
(week 5)
int f=0;
for(int i=0; i<number[arraylenth] ;i++){
int n=number[i];
if(number[i]==n){
f=f+1;
}
return f;
}
int largestdublicate(int number[arraylenth]){
int lf=-1;
int y;
for(int idx=0;idx<14;idx++){
y=frequancy(number, idx);
if(y>lf){
lf=y;
}
}
return lf;
(MONOTONIC)
#include<iostream>
using namespace std;
const int arraylenth=4;
bool ismonotonic(int numbers[arraylenth]);
bool isincreasing(int numbers[arraylenth]);
bool isdecreasing(int numbers[arraylenth]);
int main(){
int testarray[arraylenth]={1,2,7,5};
bool isarraymonotonic=ismonotonic(testarray);
if(isarraymonotonic==false){ cout<<"false";}
else{
cout<<"true";}
}
}else{
return false;
}
}
bool isincreasing(int numbers[arraylenth]){
for(int x=1;x<arraylenth;x++){
if (numbers[x-1]<numbers[x]){
}else{
return false;
}
}return true;
}
bool isdecreasing(int numbers[arraylenth]){
for(int x=1;x<arraylenth;x++){
if (numbers[x-1]>numbers[x]){
}else{
return false;
}
}return true;
}
(ROTATE ORDER)
#include<iostream>
using namespace std;
const int arraylenth=7;
}
}
void rightrotate(int numbers[],int rotation){
for(int a=0;a<rotation;a++){
int x=numbers[arraylenth-1];
int j;
for(j=arraylenth-1 ;j>0;j--){
numbers[j]=numbers[j-1];
}
numbers[0]=x;
}
}
int x;
cout<<"exam number is."<<endl;
cin>>x;
if(x>80){
cout<<"grsde is A.."<<x<<endl;
}
else if((x>=61 && x<=80)){
cout<<"grade is B.."<<endl;
}
else if((x>=51 && x<=60)){
cout<<"grade is C.."<<x;
}
else if(x<40){
cout<<" FAIL.."<<x;}
}
(Week 6)
( array to find largest)
#include<iostream>
#include<conio.h>
using namespace std;
int main(){
int num[3];
int largest=-1000;
for(int x=0;x<3;x++){if(num[x]>largest){
largest=num[x];}}
cout<<largest;
}
(ADMISSION management by array)
#include<iostream>
#include<stdlib.h>
#include<string.h>
#include<conio.h>
using namespace std;
int main(){
cout<<"*********************************************"<<endl;
cout<<"university admission management system"<<endl;
cout<<"*********************************************"<<endl;
string name[10];
float matric[10]={0,0,0,0,0,0,0,0,0,0};
float fsc[10]={0,0,0,0,0,0,0,0,0,0};
float ecat[10]={0,0,0,0,0,0,0,0,0,0};
float aggr[10];
int option;
int idx=0;
int largest=-1000;
int smallest=100;
int i=0;
while(option !=5)
{
system("CLS");
cout<<"1. add new student record "<<endl;
cout<<"2. view all record "<<endl;
cout<<"3. name and merit of top student"<<endl;
cout<<"4. name and merit of bottom student"<<endl;
cout<<"5. exist"<<endl;
cout<<"enter option ";
cin>>option;
if(option==1)
{
cout<<"enter name"<<endl;
cin>>name[idx];
cout<<"enter matric markd"<<endl;
cin>>matric[idx];
aggr[idx]=((matric[idx]/1100)*25)+((fsc[idx]/1100)*45)+((ecat[idx]/400)*30);
}getch();}
if(option==3){
for(int i=0;i<idx;i++){
if(aggr[i]>largest){
largest=aggr[i];
}}cout<<largest;
getch();}
if(option==4){
for(int i=0;i<idx;i++){
if(aggr[i]<smallest){
smallest=aggr[i];
}}cout<<smallest;
getch();}
}}
(Week7)
(MENUE BY FUNCTION)
#include<iostream>
#include<stdlib.h>
#include<string.h>
#include<conio.h>
using namespace std;
int manue();
int number[100];
int counter=0;
int option;
void addnumber();
void printnumber();
int frequancy(int f);
int replace (int r,int s);
float average();
int odd();
int largest();
int main(){
int op=100;
while(op !=8){
system("CLS");
op=manue();
if (op==1){
addnumber();
}
if (op==2){
printnumber();
getch();
}
if (op==3){
int a;
cout<<"enter frequancy no"<<endl;
cin>>a;
int result=frequancy(a);
cout<<result<<endl;
getch();
}
if(op==4){
int b,c;
cout<<"checking number"<<endl;
cin>>b;
cout<<"replacing number"<<endl;
cin>>c;
replace(b,c);
cout<<"NUMBER IS CHANGED SUCESSFULLY";
getch();
}
if(op==5){
int result=average();
cout<<"average is"<<result<<endl;
getch();
}
if(op==6){
int larger=largest();
cout<<"larger is"<<larger<<endl;
getch();
}
}
}
void addnumber(){
int newnumber;
cout<<"enter number to add"<<endl;
cin>>newnumber;
number[counter]=newnumber;
counter=counter+1;
}
void printnumber(){
for(int idx=0 ;idx<counter;idx++){
cout<<number[idx]<<endl;
}
int frequancy(int f){
int result;
for(int idx=0 ;idx<counter;idx++){
if(number[idx]==f){
result=result+1;
}
return result;
}
int replace(int r,int s ){
for(int idx=0 ;idx<counter;idx++){
if(number[idx]==r){
number[idx]=s;
}
}
return 0;
}
float average(){
int sum=1;
int result;
for(int idx=0;idx<counter;idx++){
sum=sum+number[idx];
result=sum/counter;
}
return result;
}
int largest(){
int larger=-1;
for(int idx=0;idx<counter;idx++){
if(number[idx]>larger){
larger=number[idx];
}
}
return larger;
int manue(){
int option=100;
cout<<"select option"<<endl;
cout<<"1. add new no"<<endl;
cout<<"2. print number"<<endl;
cout<<"3. frequancy of no"<<endl;
cout<<"4. find and replace the no"<<endl;
cout<<"5. print the average of all no"<<endl;
cout<<"6. print the largest no"<<endl;
cout<<"7. print the sum of all no"<<endl;
cout<<"8. exist"<<endl;
cin>>option;
return option;
}
totalfaresum=f1+f2+f3;
cout<<"total fare is"<<endl;
cout<<totalfaresum<<endl;
}
(1.2)
#include<iostream>
#include <string>
using namespace std;
int main(){
string t1,t2,t3;
int f1,f2,f3;
int total;
int km1,km2,km3;
cout<<"enter name of transport 1_";
cin>>t1;
cout<<"enter fare/km of transport 1_";
cin>>f1;
cout<<"enter km travelled by transport 1_";
cin>>km1;
cout<<"enter name of transport 2_";
cin>>t2;
cout<<"enter fare/km of transport 2_";
cin>>f2;
cout<<"enter km travelled by transport 2_";
cin>>km2;
cout<<"enter name of transport 3_";
cin>>t3;
cout<<"enter fare/km of transport 3_";
cin>>f3;
cout<<"enter km travelled by transport 3_";
cin>>km3;
total=f1*km1+f2*km2+f3*km3;
cout<<"total fare"<<total<<endl;
(2.1)
#include<iostream>
#include <string>
using namespace std;
int main(){
string t1,t2,t3;
int f1,f2,f3;
int total;
int km1,km2,km3;
int c1,c2,c3;
cout<<"enter name of transport 1_";
cin>>t1;
cout<<"enter fare/km of transport 1_";
cin>>f1;
cout<<"enter km travelled by transport 1_";
cin>>km1;
cout<<"enter name of transport 2_";
cin>>t2;
cout<<"enter fare/km of transport 2_";
cin>>f2;
cout<<"enter km travelled by transport 2_";
cin>>km2;
cout<<"enter name of transport 3_";
cin>>t3;
cout<<"enter fare/km of transport 3_";
cin>>f3;
cout<<"enter km travelled by transport 3_";
cin>>km3;
c1=f1*km1;
c2=f2*km2;
c3=f3*km3;
if(c1>c2 ||c1>c3){
cout<<t1<<c1<<endl;
}
else if(c2>c1 ||c2>c3){
cout<<t2<<c2<<endl;
}
else if(c3>c2 ||c3>c1){
cout<<t3<<c3<<endl;
}
(3.1)
#include<iostream>
#include <string>
using namespace std;
int main(){
string t1="taxi",t2="bus",t3="train";
string day="day";
string night="night";
int km;
string time;
float c1,c2,c3;
}
else if((km>20 && km<100) && (time==day ||time==night)){
c1=km*0.09;
cout<<c1<<t2<<endl;
}
else if(km>100 && (time==day ||time==night)){
c1=km*0.06;
cout<<c1<<t3<<endl;
}
(3.2)
#include<iostream>
#include <string>
using namespace std;
int main(){
string
d1="monday",d2="tuesday",d3="wednesday",d4="thirsday",d5="friday",d6="saturday",d7="su
nday";
string day;
string f1="apple",f2="banana",f3="orange",f4="grape",f5="kiwi";
string fruitname;
float qty;
float result;
cout<<"enter the day";
cin>>day;
cout<<"enter name of fruit ";
cin>>fruitname;
cout<<"enter quantity of fruit";
cin>>qty;
(4.1)
#include<iostream>
#include <string>
using namespace std;
int main(){
int x1,x2,y1,y2,x,y;
cout<<"enter x1 ";
cin>>x1;
cout<<"enter y1 ";
cin>>y1;
cout<<"enter x2 ";
cin>>x2;
cout<<"enter y2 ";
cin>>x1;
cout<<"enter x ";
cin>>x;
cout<<"enter y ";
cin>>y;
if((((x==x1) || (x==x2)) && ((y<=y1) && (y>=y2))) || (((y==y1) || (y==y2)) && ((x<=x1) &&
(x>=x2)))) {
cout<<"border";
}
else{
cout<<"inside or outside";
}}
(4.2)
#include<iostream>
#include <string>
using namespace std;
int main(){
string city;
int vsales;
float result;
string c1="lahore",c2="multan",c3="fsd";
cout<<"enter city name";
cin>>city;
cout<<"enter volume of sales";
cin>>vsales;
if(vsales<=500 && city==c1 ){
result=(vsales*5)/100;
cout<<result<<endl;
}
else if((vsales>500 && vsales<=1000) && (city==c1) ){
result=(vsales*7)/100;
cout<<result<<endl;
}
else if((vsales>1000 && vsales<=10000) && (city==c1) ){
result=(vsales*8)/100;
cout<<result<<endl;
}
else if(vsales>10000 && city==c1) {
result=(vsales*12)/100;
cout<<result<<endl;
}
//multan..
//FSD..
if(vsales<=500 && city==c3 ){
result=(vsales*5.5)/100;
cout<<result<<endl;
}
else if((vsales>500 && vsales<=1000) && (city==c3) ){
result=(vsales*8)/100;
cout<<result<<endl;
}
else if((vsales>1000 && vsales<=10000) && (city==c3) ){
result=(vsales*12)/100;
cout<<result<<endl;
}
else if(vsales>10000 && city==c3) {
result=(vsales*14.5)/100;
cout<<result<<endl;
}
//error..
else{
cout<<"error";
}
}
(5.1)
#include<iostream>
using namespace std;
int main(){
int result;
int n,a,d;
cout<<"enter N";
cin>>n;
cout<<"enter A";
cin>>a;
cout<<"enter D";
cin>>d;
for(int x=1; x<=n;x++){
cout<<a<<",",
a=a+d;
(5.2)
#include <iostream>
using namespace std;
int main(){
int num;
int sum;
while(true){
cout<<"enter no";
cin>>num;
sum=sum+num;
if(sum<=100 && num !=-1){
cout<<sum<<endl;}
else{
return 0;
}
(6.1)
#include <iostream>
using namespace std;
int main(){
int n;
int y;
int leftsum=0;
int rightsum=0;
cout<<"enter no";
cin>>n;
}
if(x>n){
rightsum=rightsum+y;
}
}
if(rightsum==leftsum){
cout<<"yes"<<" "<<"sum"<<leftsum<<endl;
}
else{
cout<<"no"<<" "<<"differ"<<leftsum-rightsum<<endl;
}
(7.1)
#include <iostream>
using namespace std;
int main(){
float num,term,count1,count2,count3,count4,count5;
cout<<"enter no of term"<<endl;
cin>>term;
for(int i=1 ; i<=term; i++){
cout<<"enter number";
cin>>num;
if(num<200){
count1=count1+1;
}
else if(num>200 && num<=400){
count2=count2+1;
}
else if(num>400 && num<600){
count3=count3+1;
}
else if(num>600 && num<800){
count4=count4+1;
}
else if(num>=800){
count5=count5+1;
}
}
cout<<count1/term*100<<endl;
cout<<count2/term*100<<endl;
cout<<count3/term*100<<endl;
cout<<count4/term*100<<endl;
cout<<count5/term*100<<endl;
}
(7.2)
#include <iostream>
using namespace std;
int main(){
int period;
int patient;
int treated=0;
int untreated=0;
int doc=7;
int sum=0;
int sum1=0;
int sum2=0;
int day=0;
cout<<"enter no of period"<<endl;
cin>>period;
for(int i=1 ; i<=period; i++){
cout<<"enter patient numbers";
cin>>patient;
day++;
if(day==4){
day=1;
}
if(day==1){
if(patient<=doc){
treated=treated+patient;
}
else{
treated=treated+doc;
untreated=untreated+(patient-doc);
}
}
if(day==2){
if(patient<=doc){
treated=treated+patient;
}
else{
treated=treated+doc;
untreated=untreated+(patient-doc);
}
}
if(day==3){
if(untreated>0){
doc++;
if(patient<=doc){
treated=treated+patient;
}
else{
treated=treated+doc;
untreated=untreated+(patient-doc);
}
}
if(untreated==0){
if(patient<=doc){
treated=treated+patient;
}
else{
treated=treated+doc;
untreated=untreated+(patient-doc);
}
}
}
}
cout<<treated<<endl;
cout<<untreated<<endl;
}
#include <string>
#include <stdlib.h>
#include <conio.h>
//Global Variables
string largerunit[ruleSize];
string smallerunit[ruleSize];
float converter[ruleSize];
int currentHistory=0;
string history[historySize];
//Function Headers.
int getUserOption();
void addConversionRule();
void convertValue();
void viewAllRules();
void pressKey();
void viewHistory();
int main(){
int option=-1;
system("CLS");
option= getUserOption();
if(option==1){
addConversionRule();
if(option==2){
viewAllRules();
getch();
pressKey();
if(option==3){
convertValue();
pressKey();
if(option==4){
viewHistory();
pressKey();
if(option==5){
return 0;
int getUserOption(){
int option=-1;
cout<<"************************************************"<<endl;
cout<<"************************************************"<<endl;
cout<<"5. Exit"<<endl;
cin>>option;
return option;
void addConversionRule(){
cout<<"enter largerunit";
cin>>largerunit[currentRule];
cout<<"enter smallerunit";
cin>>smallerunit[currentRule];
cin>>converter[currentRule];
currentRule=currentRule+1;
void viewAllRules(){
for(int idx=0;idx<currentRule;idx=idx+1){
}
}
void convertValue(){
float value;
string valueunit;
string convertingunit;
cin>>value;
cin>>valueunit;
cin>>convertingunit;
if(isRuleExist( valueunit,convertingunit)){
float multiplier=getMultiplier(valueunit,convertingunit);
float newvalue=value*multiplier;
cout<<message<<endl;
addHistory( message);
getch();
}
bool isRuleExist(string valueunit,string convertingunit){
for(int idx=0;idx<currentRule;idx++){
return true;
return true;
return false;
for(int idx=0;idx<10;idx++){
return converter[idx];
return (1/converter[idx]);
}
return 0;
history[currentHistory] = message;
currentHistory++;
void viewHistory(){
for(int x=0;x<historySize;x++){
cout<<history[x]<<endl;
}getch();
void pressKey(){
cout<<endl;
return hist;
}
(week 9)
(file palodorian)
#include <iostream>
#include <cstring>
using namespace std;
int main(){
// initiallixing the character array by
char name [30];
cout<<"enter the name or number"<<endl;
cin>>name;
//initializing the variable
int i=0 ,j= strlen (name)-1 ;
bool x=true;
for(i=0 ;i<j ;i++ ){
if(name[i] !=name[j]){
x=false;
}
j--;
}
if(x){
cout<<"the string is paladromine \n"<<endl;
}
else{
cout<<"not paladromine"<<endl;
}
}
(SIGN IN -up )
#include <iostream>
#include <fstream>
using namespace std;
void signin();
void signup();
int main(){
int option=1000;
while(option!=3){
cout<<"1. signup"<<endl;
cout<<"2. signin"<<endl;
cout<<"enter your option "<<endl;
cin>>option;
if(option==1){
signup();
}
if(option==2){
signin();
}
}
void signin(){
fstream newfile;
string name ;
string pin;
cout<<"enter your name"<<endl;
cin>>name;
cout<<"enter password"<<endl;
cin>>pin;
}
if( isusernameexist){
cout<<"valid"<<endl;
}
else{
cout<<"invalid"<<endl;
}
newfile.close();
}
void signup(){
fstream newfile;
string username ,pin ;
newfile .open("textfile.text1" ,ios::app);
cout<<"enter your name"<<endl;
cin>>username;
cout<<"enter your pin"<<endl;
cin>>pin;
newfile<<username<<endl;
newfile<<pin<<endl;
newfile .close();
}
void signin(){
fstream newfile;
string name ;
string pin;
cout<<"enter your name"<<endl;
cin>>name;
cout<<"enter password"<<endl;
cin>>pin;
}
if( isusernameexist){
cout<<"valid"<<endl;
}
else{
cout<<"invalid"<<endl;
}
newfile.close();
}
void signup(){
fstream newfile;
string username ,pin ;
newfile .open("textfile.text1" ,ios::app);
cout<<"enter your name"<<endl;
cin>>username;
cout<<"enter your pin"<<endl;
cin>>pin;
newfile<<username<<endl;
newfile<<pin<<endl;
newfile .close();
int length=0;
length=s.length();
cout<<length<<endl;
}
(printing-words-by-using-file)
#include <iostream>
#include <fstream>
using namespace std;
int main(){
fstream newfile;
newfile .open("textfile.text" ,ios::in);
string data;
while(getline(newfile,data)){
if ((data[0]=='A' || data[0]=='a') && data.length()==3){
cout<<data<<endl;
}
else{
cout<<"notfound"<<endl;
}
}
newfile.close();
(read-from-file-and-write-on-compiler)
#include <iostream>
#include <fstream>
using namespace std;
int main(){
fstream newfile;
newfile .open("textfile.text" ,ios::in);
string data;
while( getline(newfile,data)){
cout<<data<<endl;
}
(writing-word-in-file)
#include <iostream>
#include <fstream>
using namespace std;
int main(){
fstream newfile;
newfile .open("textfile.text" ,ios::out);
newfile<<"hello \n";
newfile<<"me to tekh ho sir ap sunae";
newfile<<"ant \n";
newfile<<"Anthello \n";
newfile<<"aAhello \n";
newfile<<"aak \n";
newfile<<"khamsh ho jao\n";
newfile .close();
}
(project by file system is separately hard
copied)
(week 10 end)
(week 11)
int main(){
getinput();
if(iswin('x')==true){
cout<<"x is winner"<<endl;
}
else if(iswin('o')==true){
cout<<"o is winner"<<endl;
}
else{
cout<<"match is draw"<<endl;
}
}
void showgame(){
void getinput(){
system("CLS");
int a;
int b;
for(int i=0 ; i<9; i++){
system("CLS");
showgame();
if (i%2 ==0){
cout<<"enter yor turn x"<<endl;
cin>>a;
if(a==1){
board[0][0]='x';}
else if(a==2){board[0][1]='x';}
else if(a==3){board[0][2]='x';}
else if(a==4){board[1][0]='x';}
else if(a==5){board[1][1]='x';}
else if(a==6){board[1][2]='x';}
else if(a==7){board[2][0]='x';}
else if(a==8){board[2][1]='x';}
else if(a==9){board[2][2]='x';}
}
if(board[j][i]==symbol){
counter++;
}
j-- ;
}
if(counter==3){
return true;
}
return false;
(pacman game )
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
#include <iostream>
#include <fstream>
#include<windows.h>
using namespace std;
const int gridsize1=16;
const int gridsize2=78;
int ghostx=4;
int ghosty=2;
int ghostx1=40;
int ghosty1=4;
void gotoxy( short x, short y );
char board[gridsize1][gridsize2]={};
int count=0;
int pmanx=7;
int pmany=14;
int leftLimit=0;
int rightLimit=20;
string ghostDirection="Right";
void loadgame();
void displaygame();
void movePacmanLeft();
void movePacmanRight();
void movePacmanUP();
void movePacmanDown();
void moveGhost();
void moveGhost1();
int main(void) {
system("CLS");
loadgame();
displaygame();
int x=2;
int key=4000;
bool gameRunning=true;
//showing pacman
gotoxy(pmanx,pmany);
cout<<"P";
while(gameRunning){
//scii codee for escape
if((pmanx==ghostx) && (pmany==ghosty)){
break;
}
moveGhost();
moveGhost1();
Sleep(200);
void loadgame(){
fstream newfile;
newfile.open("pacman.text" ,ios::in);
string data;
int x=0;
while (getline(newfile,data)){
for(int i=0; i<gridsize2; i++){
board[x][i]=data[i];
}
x++;
newfile.close();
}
void displaygame(){
for(int x=0; x<gridsize1;x++){
for(int y=0; y <gridsize2; y++){
cout<<board[x][y];
}
cout<<endl;
void movePacmanUP(){
gotoxy(pmanx,pmany);
cout<<" ";
int test=0;
pmany--;
test=board[pmany][pmanx];
pmany=pmany+1;
}
if(test==46){
count=count+1;
gotoxy(0,16);
cout<<"SCORE IS"<<"="<<count<<endl;
}
gotoxy(pmanx,pmany);
cout<<"P"<<endl;
void movePacmanDown(){
gotoxy(pmanx,pmany);
cout<<" ";
int test=0;
pmany++;
test=board[pmany][pmanx];
if((test==35) || (test==37) || (test==124) ||( test==38 )){
pmany=pmany-1;
}
if(test==46 ){
count=count+1;
gotoxy(0,16);
cout<<"SCORE IS"<<"="<<count<<endl;
}
gotoxy(pmanx,pmany);
cout<<"P"<<endl;
void movePacmanRight(){
gotoxy(pmanx,pmany);
cout<<" ";
int test;
pmanx++;
test=board[pmany][pmanx];
if((test==35) || (test==37) || (test==124) ||( test==38 )){
pmanx=pmanx-1;
}
if(test==46){
count=count+1;
gotoxy(0,16);
cout<<"SCORE IS "<<"="<<count<<endl;
}
gotoxy(pmanx,pmany);
cout<<"P"<<endl;
void movePacmanLeft(){
gotoxy(pmanx,pmany);
cout<<" ";
int test;
pmanx--;
test=board[pmany][pmanx];
if((test==35) || (test==37) || (test==124) ||( test==38 )){
pmanx=pmanx+1;
}
if(test==46 ){
count=count+1;
gotoxy(0,16);
cout<<"SCORE IS "<<"="<<count<<endl;
}
gotoxy(pmanx,pmany);
cout<<"P"<<endl;
}
////move ghost
void moveGhost(){
int Gposition;
gotoxy( ghostx, ghosty );
cout<<".";
board[ghosty][ghostx]='.';
if(pmany>ghosty){
ghosty++;
Gposition=board[ghosty][ghostx];
if((Gposition==35) || (Gposition==37) || (Gposition==124) ||( Gposition==38 )){
ghosty=ghosty-1;
}
else{
ghostDirection="down";
if(pmany<ghosty){
ghosty--;
Gposition=board[ghosty][ghostx];
if((Gposition==35) || (Gposition==37) || (Gposition==124) ||( Gposition==38 )){
ghosty=ghosty+1;
}
else{
ghostDirection="up";
if(pmanx>ghostx){
ghostx++;
Gposition=board[ghosty][ghostx];
if((Gposition==35) || (Gposition==37) || (Gposition==124) ||( Gposition==38 )){
ghostx=ghostx-1;
}
else{
ghostDirection="Right";
if(pmanx<ghostx){
ghostx--;
Gposition=board[ghosty][ghostx];
if((Gposition==35) || (Gposition==37) || (Gposition==124) ||( Gposition==38 )){
ghostx=ghostx+1;
}
else{
ghostDirection="left";
}
gotoxy( ghostx, ghosty );
cout<<"G";
////move ghost 2
void moveGhost1(){
int Gposition;
gotoxy( ghostx1, ghosty1 );
cout<<".";
board[ghostx1][ghosty1]='.';
if(pmany>ghosty1){
ghosty1++;
Gposition=board[ghosty1][ghostx1];
if((Gposition==35) || (Gposition==37) || (Gposition==124) ||( Gposition==38 )){
ghosty1=ghosty1-1;
}
else{
ghostDirection="down";
}
if(pmany<ghosty1){
ghosty1--;
Gposition=board[ghosty1][ghostx1];
if((Gposition==35) || (Gposition==37) || (Gposition==124) ||( Gposition==38 )){
ghosty1=ghosty1+1;
}
else{
ghostDirection="up";
if(pmanx>ghostx1){
ghostx1++;
Gposition=board[ghosty1][ghostx1];
if((Gposition==35) || (Gposition==37) || (Gposition==124) ||( Gposition==38 )){
ghostx1=ghostx1-1;
}
else{
ghostDirection="Right";
}
}
if(pmanx<ghostx1){
ghostx1--;
Gposition=board[ghosty1][ghostx1];
if((Gposition==35) || (Gposition==37) || (Gposition==124) ||( Gposition==38 )){
ghostx1=ghostx1+1;
}
else{
ghostDirection="left";
}
gotoxy( ghostx1, ghosty1 );
cout<<"g";
}
////gotoxy function
(Week 11 end)
(week 12)
(2dsorted-every-row)
#include <conio.h>
#include <iostream>
using namespace std;
void sortrowwise(int board[4][4],int row,int column);
int main(){
int board[4][4]={
{1,7,8,9},
{2,0,3,7},
{2,3,5,9},
{2,1,3,6}
};
//row is 4
//column is 4 that we pass to the function
sortrowwise(board,4, 4);
return 0;
}
int board[4][4]={
{1,2,3,4},
{5,6,7,8},
{9,10,11,12},
{13,14,15,16}
};
sortingmatrix(board);
}
for(int x =0;x<4;x++){
for(int y=0;y<4;y++){
int largest=-1000;
int largesti=-1000;
int largestj=-1000;
for(int i=0;i<4;i++){
for(int j=0; j<4; j++){
if(board[i][j]>largest){
largest=board[i][j];
largesti=i;
largestj=j;
}
}
}
board[largesti][largestj]=-10000;
sorted[x][y]=largest;
}
}
cout<<endl;
cout<<"show sorted matrix "<<endl;
for(int i=0; i<4; i++){
for(int j=0; j<4; j++){
cout<<sorted[i][j]<<" ";
}
cout<<endl;
}
(adding-pointer-adress)
#include <iostream>
using namespace std;
int main(){
int a;
int b;
cout<<"enter 1st no"<<endl;
cin>>a;
(file2dtranspose)
#include <conio.h>
#include <iostream>
using namespace std;
int board1[3][3] ;
int main(){
cout<<"enter element for 1stmatrix"<<endl;
for(int i=0 ;i<3;i++){
for(int j=0; j<3; j++){
cin>>board1[i][j];
}
cout<<endl;
cout<<"enter transpose of matrix"<<endl;
for(int i=0; i<3; i++){
for(int j=0; j<3; j++){
cout<<board1[j][i]<<" ";
}
cout<<endl;
}
return 0;
(pointer_to_print_adress)
#include <iostream>
using namespace std;
int main(){
float value1=2.5;
float *pointervalue1=&value1;
float value2=3.5;
float *pointervalue2=&value2;
float value3=4.5;
float *pointervalue3=&value3;
cout<<pointervalue1<<endl ;
cout<<pointervalue2 <<endl ;
cout<<pointervalue3 <<endl ;
}
(sum of 2D matrix)
#include <conio.h>
#include <iostream>
using namespace std;
int board1[4][3] ;
int board2[4][3] ;
int main(){
cout<<"ENTER ELEMENT OF 1st MATRIX"<<endl;
cout<<endl;
cout<<endl;
for(int i=0 ;i<4;i++){
for(int j=0; j<3; j++){
cout<<"enter element in row "<<i+1<<" colum"<<j+1<<":";
cin>>board1[i][j];
}
cout<<endl;
cout<<endl;
cout<<"ENTER ELEMENT OF 2st MATRIX"<<endl;
cout<<endl;
cout<<endl;
for(int i=0 ;i<4;i++){
for(int j=0; j<3; j++){
cout<<"enter element in row "<<i+1<<" colum"<<j+1<<":";
cin>>board2[i][j];
}
}
cout<<endl;
cout<<"enter sum of matrix"<<endl;
for(int i=0; i<4; i++){
for(int j=0; j<3; j++){
cout<<board1[i][j]+board2[i][j]<<" ";
}
cout<<endl;
}
return 0;