0% found this document useful (0 votes)
13 views

LAB Assignment

Uploaded by

dsgravity402
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views

LAB Assignment

Uploaded by

dsgravity402
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 33

LAB Assignment – 1

Question 1:

#include<iostream>

using namespace std;

int main(){

int n,a,b;

cout<<"Tarum Singh"<<endl;

cout<<"Roll no. : 22CHB0A51"<<endl;

cout<<"enter a four digit number :";

cin>>n;

a=n/1000;

b=n%10;

cout<<"sum of first and last digit is "<<a+b;

return 0;

}
Question 2

#include<iostream>

using namespace std;

int main (){

int l,b,c;

cout<<"Tarum Singh"<<endl;

cout<<"Roll no. : 22CHB0A51"<<endl;

l=1189,b=841;

cout<<"A0="<<l<<"mm"<<"*"<<b<<"mm"<<endl;

c=l;

l=b;

b=c/2;

cout<<"A1="<<l<<"mm"<<"*"<<b<<"mm"<<endl;

c=l;

l=b;

b=c/2;

cout<<"A2="<<l<<"mm"<<"*"<<b<<"mm"<<endl;

c=l;

l=b;

b=c/2;

cout<<"A3="<<l<<"mm"<<"*"<<b<<"mm"<<endl;

c=l;

l=b;

b=c/2;
cout<<"A4="<<l<<"mm"<<"*"<<b<<"mm"<<endl;

c=l;

l=b;

b=c/2;

cout<<"A5="<<l<<"mm"<<"*"<<b<<"mm"<<endl;

c=l;

l=b;

b=c/2;

cout<<"A6="<<l<<"mm"<<"*"<<b<<"mm"<<endl;

c=l;

l=b;

b=c/2;

cout<<"A7="<<l<<"mm"<<"*"<<b<<"mm"<<endl;

c=l;

l=b;

b=c/2;

cout<<"A8="<<l<<"mm"<<"*"<<b<<"mm"<<endl;

return 0;

}
Question 3.

#include<iostream>

using namespace std;

int main (){

int be,te,fe,le,total;

float bp,tp,fp,lp;

cout<<"Tarum Singh"<<endl;

cout<<"Roll no. : 22CHB0A51"<<endl;

cout<<"Enter branding expenses : ";

cin>>be;

cout<<"Enter travel expenses : ";

cin>>te;

cout<<"Enter food expenses : ";

cin>>fe;

cout<<"Enter logistics expenses : ";

cin>>le;

total=be+te+le+fe;

cout<<"Total expenses: "<<total;

bp=1.0*be/total*100;

tp=1.0*te/total*100;

fp=1.0*fe/total*100;

lp=1.0*le/total*100;

cout<<"Branding expenses percentage : "<<bp<<"%"<<endl;


cout<<"Travel expenses percentage : "<<tp<<"%"<<endl;

cout<<"Food expenses percentage : "<<fp<<"%"<<endl;

cout<<"Logistics expenses percentage : "<<lp<<"%"<<endl;

return 0;
Question 4.

#include<iostream>

using namespace std;

int main(){

float cm,m,km;

cout<<"Tarum Singh"<<endl;

cout<<"Roll no. : 22CHB0A51"<<endl;

cout<<"enter the value in centimeter="<<endl;

cin>>cm;

m=cm/100;

km=m/1000;

cout<<"the value in metre="<<m<<endl;

cout<<"the value in kilometre="<<km<<endl;

return 0;

}
Question 5.

#include<iostream>

using namespace std;

int main(){

int p,t,r;

float s;

cout<<"Tarum Singh"<<endl;

cout<<"Roll no. : 22CHB0A51"<<endl;

cout<<"value of principle=";

cin>>p;

cout<<"value of time=";

cin>>t;

cout<<"value of rate=";

cin>>r;

s=p*t*r/100;

cout<<"simple interest="<<s<<endl;

return 0;

}
Question 6.

#include<iostream>

using namespace std;

int main (){

cout<<"Tarum Singh"<<endl;

cout<<"Roll no. : 22CHB0A51"<<endl;

int a,b,c,d,e,f,t;

float g;

cout<<"enter 6 subject a,b,c,d,e,f"<<endl;

cin>>a>>b>>c>>d>>e>>f;

t=a+b+c+d+e+f;

cout<<"aggregate mark="<<t<<endl;

g=(t*100)/600;

cout<<"percentage by the student= "<<g<<"%";

return 0;

}
Question 7.

#include<iostream>

using namespace std;

int main (){

char ch;

cout<<"Tarum Singh"<<endl;

cout<<"Roll no. : 22CHB0A51"<<endl;

cout<<"enter the character=";

cin>>ch;

int a;

a=ch;

cout<<"ASCII value of character="<<a<<endl;


return 0;

}
Question 8.

#include<iostream>

using namespace std;

int main (){

int a,b,c,d,e,f,g,h,i,j,k,l,m;

cout<<"Tarum Singh"<<endl;

cout<<"Roll no. : 22CHB0A51"<<endl;

cout<<"enter the amount=";

cin>>a;

b=a/100;

c=a%100;

d=c/50;

e=c%50;

f=e/10;

g=e%10;

h=g/5;

i=g%5;

j=i/2;

k=i%2;

l=k/1;

m=b+d+f+h+j+l;

cout<<"mini number of note="<<m;

return 0;
}
Question 9.

#include<iostream>

using namespace std;

int main (){

int days,year,mon,a;

cout<<"Tarum Singh"<<endl;

cout<<"Roll no. : 22CHB0A51"<<endl;

cout<<"enter number of days:";

cin>>days;

year=days/365;

a=days%365;

mon=a/30;

a=a%30;

days=a;

cout<<year<<"year"<<mon<<"month"<<days<<"days";

return 0;

}
Question 10.

#include<iostream>

using namespace std;

int main(){

float a,b,c,d,e,f,g;

cout<<"Tarum Singh"<<endl;

cout<<"Roll no. : 22CHB0A51"<<endl;

cout<<"enter the reading at start in km"<<endl;

cin>>a;

cout<<"enter the reading of fuel at start in liter"<<endl;

cin>>b;

cout<<"enter the reading at end in km"<<endl;

cin>>c;

cout<<"enter the reading at end in liter"<<endl;

cin>>d;

e=c-a;

f=b-d;

g=e/f;

cout<<"the total dist travelled is"<<e<<endl;

cout<<"the total fuel used is"<<f<<endl;

cout<<"the fuel consumption in km per liter is "<<g<<endl;

return 0;

}
Question 11.

#include<iostream>

using namespace std;

int main(){

int a,b,c,d,e;

cout<<"Tarum Singh"<<endl;

cout<<"Roll no. : 22CHB0A51"<<endl;

cout<<"enter the value of a:"<<endl;

cin>>a;

cout<<"value b:";

cin>>b;

cout<<"value d:";

cin>>d;

cout<<"value e:";

cin>>e;

a=a<<b;

cout<< "a value after left shift"<<a<<endl;

c=d>>e;

cout<<"c value after right shift"<<c<<endl;

return 0;

}
Question 12.

#include<iostream>

using namespace std;

int main(){

int a,b,c,d,e;

cout<<"Tarum Singh"<<endl;

cout<<"Roll no. : 22CHB0A51"<<endl;

cout<<"enter the value of a:";

cin>>a;

cout<<"value b:";

cin>>b;

c=a&b;

cout<<"the value of bitwise of a AND b operator="<<c<<endl;

d=a|b;

cout<<"the value of bitwise of a OR b operator="<<d<<endl;

e=a^b;

cout<<"the value of bitwise of a XOR b operator="<<e<<endl;

return 0;

}
Question 13.

#include<iostream>

using namespace std;

int main(){

int a,b,c;

cout<<"Tarum Singh"<<endl;

cout<<"Roll no. : 22CHB0A51"<<endl;

cout<<"USING 3RD VARIABLE"<<endl;

cout<<"enter the value of a:";

cin>>a;

cout<<"value b:";

cin>>b;

cout<<"before swap a="<<a<<endl;

cout<<"before swap b="<<b<<endl;

c=a;

a=b;

b=c;

cout<<"after swap a="<<a<<endl;

cout<<"after swap b="<<b<<endl;

return 0;

}
Question 14.

#include<iostream>

using namespace std;

int main(){

int a,b,c;

cout<<"Tarum Singh"<<endl;

cout<<"Roll no. : 22CHB0A51"<<endl;

cout<<"without USING 3RD VARIABLE"<<endl;

cout<<"enter the value of a:";

cin>>a;

cout<<"value b:";

cin>>b;

cout<<"before swap a="<<a<<endl;

cout<<"before swap b="<<b<<endl;

a=a+b;

b=a-b;

a=a-b;
cout<<"after swap a="<<a<<endl;

cout<<"after swap b="<<b<<endl;

return 0;

}
Question 15.

#include<iostream>

using namespace std;

int main(){

cout<<"Tarum Singh"<<endl;

cout<<"Roll no. : 22CHB0A51"<<endl;

int t;

float x;

cout<<"enter the value total no.of people=";

cin>>t;

x=2.0*t/7;

cout<<"no. of people attended the event on the 1 day="<<x<<endl;

cout<<"no. of people attended the event on the 2 day="<<2*x<<endl;

cout<<"no. of people attended the event on the 3 day="<<x/2.0<<endl;

return 0;

You might also like