C++ Assignment

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 61

LAB EXERCISE 1

/*Lab Exercise 1.1 TO FIND THE AREA OF A RECTANGLE WITH LENGTH 10 AND BREADTH 20 By- Vikas Tomar XI-D*/

#include<iostream.h> void main() { int int length= 10; breadth =20;

cout<<"\nAREA OF THE RECTANGLE= "<<length*breadth; } /*OUTPUT:AREA OF THE RECTANGLE= 200 */

/*LAB EXERCISE 1.2 TO FIND THE PERIMETER AND AREA OF A RECTANGLE By- Vikas Tomar XI-D*/

#include<iostream.h> void main() {int l,b;

cout<<"Enter The Length Of The Rectangle : "; cin>>l; cout<<"Enter The Breadth Of The Rectangle: "; cin>>b;

cout<<"PERIMETER OF THE RECTANGLE= "<<2*(l+b); cout<<"\nAREA OF THE RECTANGLE } = "<<l*b;

/*OUTPUT:Enter The Length Of The Rectangle : 15 Enter The Breadth Of The Rectangle: 15 PERIMETER OF THE RECTANGLE= 60 AREA OF THE RECTANGLE */ = 225

/*LAB EXERCISE 1.3 TO CONVERT CELCIUS INT O FARENHEIT AND VICE-VERSA By- Vikas Tomar XI-D*/ #include<iostream.h> void main() {float f,c;

cout<<"Enter Temprature1 in Farenheits: "; cin>>f; c=(5.0/9)*(f-32); cout<<"TEMPRATURE1 IN CELCIUS= "<<c<<"C"; cout<<"\n\nEnter Temprature in Celcius cin>>c; f=(9.0/5)*c+32; cout<<"TEMPRATURE2 IN FARENHEIT= "<<f<<"F"; } /*OUTPUT:Enter Temprature1 in Farenheits: 98.6 TEMPRATURE1 IN CELCIUS= 37C : ";

Enter Temprature in Celcius

: -40

TEMPRATURE2 IN FARENHEIT= -40F*/

/*LAB EXERCISE 1.4 TO FIND LATERAL SURFACE AREA, TOTAL SURFACE AREA AND VOLUME OF CUBOID By- Vikas Tomar XI-D*/ #include<iostream.h> void main() {int l,b,h;

cout<<"Enter the length of cuboid : "; cin>>l; cout<<"Enter the breadth of cuboid: "; cin>>b; cout<<"Enter the height of cuboid : "; cin>>h; cout<<"\nLATERAL SURFACE AREA OF CUBOID= "<<2*(l+b)*h; cout<<"\nTOTAL SURFACE AREA OF CUBOID cout<<"\nVOLUME OF CUBOID } = "<<2*(l*b+b*h+h*l); = "<<l*b*h;

/*OUTPUT:Enter the length of cuboid : 2 Enter the breadth of cuboid: 4 Enter the height of cuboid : 5

LATERAL SURFACE AREA OF CUBOID= 60 TOTAL SURFACE AREA OF CUBOID VOLUME OF CUBOID */ = 76 = 40

/*LAB EXERCISE 1.5 TO FIND LATERAL SURFACE AREA, TOTAL SURFACE AREA AND VOLUME OF CONE By- Vikas Tomar XI-D*/ #include<iostream.h>

#include<math.h> void main() {float r,h,l;

cout<<"Enter the radius of the cone: "; cin>>r; cout<<"Enter the height of the cone: "; cin>>h;

l=sqrt(r*r+h*h) ; cout<<"LATERAAL SURFACE AREA OF THE CONE= "<<(22.0/7)*l*r; cout<<"\nTOTAL SURFACE AREA OF THE CONE = "<<(22.0/7)*r*(l+r); cout<<"\nVOLUME OF THE CONE } /*OUTPUT;Enter the radius of the cone: 7 Enter the height of the cone: 14 LATERAAL SURFACE AREA OF THE CONE= 344.354 TOTAL SURFACE AREA OF THE CONE = 498.354 VOLUME OF THE CONE */ = 102.667 = "<<(1.0/3)*(22.0/7)*r*h;

/*LAB EXERCISE 1.6 TO FIND SIMPLE INT EREST AND COMPOUD INT EREST By- Vikas Tomar XI-D*/ #include<iostream.h> #include<math.h> void main() {unsigned int float c,i,a; p,r,t;

cout<<"ENTER PRINCIPAL AMOUNT: "; cin>>p;

cout<<"ENTER RATE (%) cin>>r; cout<<"ENTER TIME PERIOD cin>>t;

: ";

: ";

i=(p*r*t)/100.0; a=p*pow((1+r/100.0),t); c=a-p; cout<<"\nSIMPLE INT EREST = "<<i;

cout<<"\nCOMPOUND INT EREST= "<<c; cout<<"\nAMOUNT } = "<<a;

/*OUTPUT:ENTER PRINCIPAL AMOUNT: 1000 ENTER RATE (%) ENTER TIME PERIOD : 10 : 1

SIMPLE INT EREST

= 100

COMPOUND INT EREST= 100 AMOUNT */ = 1100

/*LAB EXERCISE 1.7 TO SWAP THE VALUES OF TWO VARIABLES USING THIRD VARIABLE By- Vikas Tomar XI-D*/ #include<iostream.h> void main() {int x,y,z;

cout<<"ENTER VARIABLE 'X': "; cin>>x;

cout<<"ENTER VARIABLE 'Y': "; cin>>y; cout<<"\nBEFORE SWAPPING:-"; cout<<"\nVARIABLE 'X'= "<<x<<" VARIABLE 'Y'= "<<y; z=x; x=y; y=z; cout<<"\nAFTER SWAPPING:-"; cout<<"\nVARIABLE 'X'= "<<x<<" VARIABLE 'Y'= "<<y; } /*OUTPUT:ENTER VARIABLE 'X': 5 ENTER VARIABLE 'Y': 4

BEFORE SWAPPING:VARIABLE 'X'= 5 VARIABLE 'Y'= 4 AFTER SWAPPING:VARIABLE 'X'= 4 VARIABLE 'Y'= 5 */

/*LAB EXERCISE 1.7 TO SWAP THE VALUES OF TWO VARIABLES WITHOUT USING THIRD VARIABLE By- Vikas Tomar XI-D*/ #include<iostream.h> void main() {int x,y;

cout<<"ENTER VARIABLE 'X': "; cin>>x; cout<<"ENTER VARIABLE 'Y': "; cin>>y; cout<<"\nBEFORE SWAPPING:-";

cout<<"\nVARIABLE 'X'= "<<x<<" VARIABLE 'Y'= "<<y; x=x+y; y=x-y; x=x-y; cout<<"\nAFTER SWAPPING:-"; cout<<"\nVARIABLE 'X'= "<<x<<" VARIABLE 'Y'= "<<y; } /*OUTPUT:ENTER VARIABLE 'X': 4 ENTER VARIABLE 'Y': 5

BEFORE SWAPPING:VARIABLE 'X'= 4 VARIABLE 'Y'= 5 AFTER SWAPPING:VARIABLE 'X'= 5 VARIABLE 'Y'= 4 */

LAB EXERCISE 2

/*LAB EXERCISE 2.1 TO DISPLAY REVERSE OF A NUMBER ENTERED BY THE USER By- Vikas Tomar XI-D */

#include<iostream.h> void main () { int N, TH, H, T, U;

cout<<"ENTER THE FOUR DIGITS NUMBER: " ; cin>>N; TH=N%10; N= N/10 ; H= N%10 ; N= N/10 ; T= N%10 ; N= N/10 ; U= N%10 ; N= N/10 ;

cout<<"\nSUM OF THE DIGITS : "<<TH+H+T+U;

int int int int

u= TH*1000; t= H*100; h= T*10; th= U;

cout<<"\nREVERSE OH THE NUMBER IS: "<<u+t+h+th; }

/*OUTPUT;-

ENTER THE FOUR DIGITS NUMBER: 6789

SUM OF THE DIGITS : 30 REVERSE OH THE NUMBER IS: 9876 */

/*LAB EXERCISE 2.2 TO FIND THE NUMBER OF HOURS , MINUTES AND SECONDS WHEN SECONDS ARE ENTERED BY USER By- Vikas Tomar XI-D*/

#include<iostream.h> void main () { unsigned long int n;

cout<<"ENTER NUMBER OF SECONDS : "; cin>>n;

cout<<"\nHOURS n=n%3600;

: "<<n/3600;

cout<<"\nMINUTES : "<<n/60; n=n%60; cout<<"\nSECONDS : "<<n;

/*OUTPUT:ENTER NUMBER OF SECONDS : 7322

HOURS

: 2

MINUTES : 2 SECONDS : 2 */

/*Lab Exercise 2.3 TO FIND THE NUMBER OF YEARS, MONTHS AND DAYS WHEN DAYS ARE ENTERED BY USER AS INT EGERS By - VIKAS TOMAR XI-D*/ #include<iostream.h> void main() { int n;

cout<<"ENTER THE NUMBER OF DAYS: "; cin>>n; cout<<"\nYEARS n=n%365; cout<<"\nMONTHS : "<<n/30; n=n%30; cout<<"\nDAYS } /*OUTPUT:ENTER THE NUMBER OF DAYS: 396 : "<<n; : "<<n/365;

YEARS

: 1

MONTHS : 1 DAYS : 1

/*LAB EXERCISE 2.4 To Add Two Length Entered By The User By- Vikas Tomar XI-D*/

#include<iostream.h> void main() {int L1,l1,L2,l2;

cout<<"Enter the first length(meters) cin>>L1;

: ";

cout<<"\nEnter the first lenght(centimeter): "; cin>>l1; cout<<"\nEnter the second length(meters) cin>>L2; cout<<"\nEnter the second length(centimeter): "; cin>>l2; cout<<"\nSUM OF THE LENGTHS: "<<L1+L2<<"m "<<l1+l2<<"cm"; } : ";

/*OUTPUT:-

Enter the first length(meters)

: 10

Enter the first lenght(centimeter): 5 Enter the second length(meters) : 5

Enter the second length(centimeter): 10

SUM OF THE LENGTHS: 15m 15cm */

/*LAB EXERCISE 2.5 TO FIND THE NUMBER OF NOTES OF Rs.1000, Rs.500, Rs.100, Rs.50, Rs.20, Rs.10 Rs.5 & Re.1 By- Vikas Tomar XI-D*/

#include<iostream.h>

void main() { unsigned long n; cout<<"ENTER AMOUNT : Rs. "; cin>>n; cout<<"\nNUMBER OF NOTES ARE AS FOLLOWS"; cout<<"\nRs.1000 n=n%1000; cout<<"\nRs.500 n=n%500; cout<<"\nRs.100 n=n%100; cout<<"\nRs.50 n=n%50; cout<<"\nRs.20 n=n%20; cout<<"\nRs.10 n=n%10; cout<<"\nRs.5 n=n%5; cout<<"\nRe.1 } : "<<n; : "<<n/5; : "<<n/10; : "<<n/20; : "<<n/50; : "<<n/100; : "<<n/500; : "<<n/1000;

/*OUTPUT:ENTER AMOUNT : Rs. 1686

NUMBER OF NOTES ARE AS FOLLOWS Rs.1000 Rs.500 Rs.100 : 1 : 1 : 1

Rs.50 Rs.20 Rs.10 Rs.5 Re.1 */

: 1 : 1 : 1 : 1 : 1

LAB EXERCISE 3

/*LAB EXERCISE 3.1 TO CHECK WHETHER A GIVEN NUMBER IS ODD OR EVEN Vikas Tomar XI-D*/ #include<iostream.h> void main() {int n;

cout<<"ENTER A NUMBER: "; cin>>n; (n%2==0)?cout<<"THE NUMBER IS EVEN.":cout<<"THE NUMBER IS ODD."; } /*OUTPUT:ENTER A NUMBER: 5 THE NUMBER IS ODD.

ENTER A NUMBER: 4 THE NUMBER IS EVEN. */

/*LAB EXERCISE 3.2 TO CHECK WHETHER A GIVEN NUMBER IS POSITIVE OR NEGATIVE Vikas Tomar XI-D*/ #include<iostream.h> void main() {int n;

cout<<"ENTER A NUMBER: "; cin>>n; (n>0)?cout<<"THE NUMBER IS POSITIVE.":cout<<"THE NUMBER IS NEGATIVE."; } /*OUTPUT:ENTER A NUMBER: 5 THE NUMBER IS POSITIVE.

ENTER A NUMBER: -5 THE NUMBER IS NEGATIVE. */

/*LAB EXERCISE 3.3 TO FIND THE GREATEST NUMBER AMONG THE THREE UNEQUAL NUMBERS Vikas Tomar XI-D*/ #include<iostream.h> void main() {int a,b,c;

cout<<"ENTER THE VALUE OF 'A': "; cin>>a; cout<<"ENTER THE VALUE OF 'B': "; cin>>b; cout<<"ENTER THE VALUE OF 'C': "; cin>>c;

((a>b)&&(a>c))?cout<<"\n'A' IS GREATEST AMONG THE THREE ENTERED VARIABLE":((b>c)&&(b>a))?cout<<"\n'B' IS GREATEST AMONG THE THREE ENTERED VARIABLE":cout<<"\n'C' IS GREATEST AMONG THE THREE ENTERED VARIABLE"; } /*OUTPUT:ENTER THE VALUE OF 'A': 4 ENTER THE VALUE OF 'B': 5 ENTER THE VALUE OF 'C': 6

'C' GREATEST AMONG THE THREE ENTERED VARIABLE */

/*LAB EXERCISE 3.4 TO FIND THE GRADE BASED ON MARKS Vikas Tomar XI-D*/ #include<iostream.h> void main() {int M;

cout<<"ENTER YOUR MARKS: "; cin>>M; (M>90)?cout<<"GRADE 'A'":(M>80)?cout<<"GRADE 'B'":(M>70)?cout<<"GRADE 'C'":(M>50)?cout<<"GRADE 'D'":(M>40)?cout<<"GRADE 'E'":cout<<"FAIL"; } /*OUTPUT:ENTER YOUR MARKS: 99 GRADE 'A' ENTER YOUR MARKS: 88 GRADE 'B' ENTER YOUR MARKS: 77 GRADE 'C' ENTER YOUR MARKS: 66 GRADE 'D' ENTER YOUR MARKS: 44 GRADE 'E' */

/*LAB EXERCISE 3.5 TO CALCULATE THE ELECTRICITY BILL Vikas Tomar XI-D*/ #include<iostream.h> void main() {int f=200; u,f;

cout<<"ENTER NUMBER OF UNITS: "; cin>>u; (u<=100)?cout<<"BILL= "<<f+(5*u):(u<=200)?cout<<"BILL= "<<f+500+6*(u100):(u<=500)?cout<<"BILL= "<<f+1100+7*(u-200):cout<<"BILL= "<<f+3200+10*(u-500); }

/*OUTPUT:ENTER NUMBER OF UNITS: 50 BILL= 450

ENTER NUMBER OF UNITS: 150 BILL= 1000

ENTER NUMBER OF UNITS: 240 BILL= 1580

ENTER NUMBER OF UNITS: 520 BILL= 3600 */

/* LAB EXERCISE 3.6 PROGRAM TO CALCULATE INCOME TAX TO BE PAID ON THE BASIS OF ANNUAL INCOME BY VIKAS TOMAR XI-D*/

#include<iostream.h> void main() { float s,I;

cout<<"ENTER YOUR ANNUAL INCOME:Rs. ";

cin>>s;

I=(s<=100000)?0:(s<=200000)?0.1*(s-100000):(s<=500000)?10000+0.2*(s200000): 70000+0.3*(s-500000);

I=I+(0.12*I); cout<<"TAX TO BE PAID BY YOU= Rs. "<<I ; cout<<"\nYOUR FINAL ANNUAL SALARY=Rs. "<<s-I; }

/*OUTPUTENTER YOUR ANNUAL INCOME: 300000 TAX TO BE PAID BY YOU= Rs. 33600 */

/*LAB EXERCISE 3.7 TO FIND THE ROOTS OF A QUADRATIC EQUATION Vikas Tomar XI-D*/ #include<iostream.h> #include<math.h> void main() {int int a,b,c,D; d;

cout<<"ENTER THE COEFFICIENT OF x^2: "; cin>>a; cout<<"ENTER THE COEFFICIENT OF x cin>>b; cout<<"ENTER THE VALUE OF CONSTANT : "; cin>>c; : ";

D= (b*b)-4*a*c; d= (b*b)-4*a*c; (D>0)?cout<<"REAL AND DISTINCT ROOTS EXIST"<<" \nROOT1 = "<<(b+sqrt(D))/(2*a)<<" \nROOT2 = "<<(-b-sqrt(D))/(2*a):(D==0)?cout<<"REAL AND EQUAL ROOTS EXIST"<<" \nROOT1=ROOT2= "<<-b/(2*a):cout<<"NO REAL ROOTS EXIST"; } /*OUTPUT:ENTER THE COEFFICIENT OF x^2: 1 ENTER THE COEFFICIENT OF x : 0

ENTER THE VALUE OF CONSTANT : -9 REAL AND DISTINCT ROOTS EXIST ROOT1 = 3 ROOT2 = -3

ENTER THE COEFFICIENT OF x^2: 1 ENTER THE COEFFICIENT OF x : 6

ENTER THE VALUE OF CONSTANT : 9 REAL AND EQUAL ROOTS EXIST ROOT1=ROOT2= -3

ENTER THE COEFFICIENT OF x^2: 1 ENTER THE COEFFICIENT OF x : 0

ENTER THE VALUE OF CONSTANT : 4 NO REAL ROOTS EXIST */

/*LAB EXERCISE 3.8 TO CALCULATE LOSS OR GAIN PERCENT Vikas Tomar XI-D*/ #include<iostream.h> void main()

{float

cp,sp; : ";

cout<<"ENTER THE COST PRICE cin>>cp;

cout<<"ENTER THE SELLING PRICE: "; cin>>sp;

(cp>sp)?cout<<"LOSS OF "<<((cp-sp)/cp)*100.0<<"%":(cp==sp)?cout<<"NO PROFIT NO LOSS":cout<<"PROFIT OF "<<((sp-cp)/cp)*100.0<<"%"; } /*OUTPUT:ENTER THE COST PRICE : 100

ENTER THE SELLING PRICE: 110 PROFIT OF 10%

ENTER THE COST PRICE

: 100

ENTER THE SELLING PRICE: 90 LOSS OF 10% */

/*LAB EXERCISE 3.9 TO COMPARE LATERAL SURFACE AREA, TOTAL SURACE AREA AND VOLUME OF TWO CONES By- Vikas Tomar XI-D*/

#include<iostream.h> #include<math.h>

void main() { int float r1,r2,h1,h2; l1,l2,ls1,ls2,ts1,ts2,v1,v2 ; : ";

cout<<"ENTER RADIUS OF FIRST CONE

cin>>r1; cout<<"\nENTER HEIGHT OF FIRST CONE cin>>h1; cout<<"\nENTER RADIUS OF SECOND CONE : "; cin>>r2; cout<<"\nENTER HEIGHT OF SECOND CONE : "; cin>>h2; : ";

v1= 1.0/3*(22.0/7)*r1*r1*h1; l1=sqrt(r1*r1+h1*h1); ls1=(22.0/7)*r1*l1; ts1=(22.0/7)*r1*(l1+r1); v2= 1.0/3*(22.0/7)*r2*r2*h2; l2=sqrt(r2*r2+h2*h2); ls2=(22.0/7)*r2*l2; ts2=(22.0/7)*r2*(l2+r2);

cout<<"\nSLANT HEIGHT OF FIRST CONE cout<<"\nLATERAL SURFACE AREA OF FIRST CONE cout<<"\nTOTAL SURFACE AREA OF FIRST CONE cout<<"\nVOLUME OF FIRST CONE cout<<"\n\nSLANT HEIGHT OF SECOND CONE

= "<<l1; = "<<ls1; = "<<ts1; = "<<v1; = "<<l2;

cout<<"\nLATERAL SURFACE AREA OF SECOND CONE = "<<ls2; cout<<"\nTOTAL SURFACE AREA OF SECOND CONE cout<<"\nVOLUME OF SECOND CONE = "<<ts2; = "<<v2;

if (l1>l2) cout<<"\n\nS.H. OF FIRST CONE > S.H. OF SECOND CONE BY "<<l1-l2; else if (l1==l2) cout<<"\nSLANT HEIGHTS OF BOTH THE CONES ARE SAME"; else

cout<<"\nS.H OF SECOND CONE > S.H. OF FIRST CONE BY "<<l2-l1;

if (ls1>ls2) cout<<"\n\nLSA OF FIRST CONE > LSA OF SECOND CONE BY "<<ls1-ls2; else if (ls1==ls2) cout<<"\n\nLSAs OF BOTH THE CONES ARE SAME"; else cout<<"\n\nLSA OF SECOND CONE > LSA OF FIRST CONE BY "<<ls2-ls1;

if (ts1>ts2) cout<<"\n\nTSA OF FIRST CONE > TSA OF SECOND CONE BY "<<ts1-ts2; else if (ts1==ts2) cout<<"\n\nTSAs OF BOTH THE CONES ARE SAME"; else cout<<"\n\nTSA OF SECOND CONE > TSA OF FIRST CONE BY "<<ts2-ts1;

if (v1>v2) cout<<"\n\nVOLUME OF FIRST CONE > VOLUME OF SECOND CONE BY "<<v1-v2; else if (v1==v2) cout<<"\n\nVOLUMES OF BOTH THE CONES ARE SAME"; else cout<<"\n\nVOLUME OF SECOND CONE > VOLUME OF FIRST CONE BY "<<v2-v1; }

/*OUTPUT:ENTER RADIUS OF FIRST CONE : 1

ENTER HEIGHT OF FIRST CONE

: 2

ENTER RADIUS OF SECOND CONE : 2

ENTER HEIGHT OF SECOND CONE : 1

SLANT HEIGHT OF FIRST CONE LATERAL SURFACE AREA OF FIRST CONE TOTAL SURFACE AREA OF FIRST CONE VOLUME OF FIRST CONE

= 2.23607 = 7.02764 = 10.1705 = 2.09524

SLANT HEIGHT OF SECOND CONE

= 2.23607

LATERAL SURFACE AREA OF SECOND CONE = 14.0553 TOTAL SURFACE AREA OF SECOND CONE VOLUME OF SECOND CONE = 26.6267 = 4.19048

SLANT HEIGHTS OF BOTH THE CONES ARE SAME

LSA OF SECOND CONE > LSA OF FIRST CONE BY 7.02764

TSA OF SECOND CONE > TSA OF FIRST CONE BY 16.4562

VOLUME OF SECOND CONE > VOLUME OF FIRST CONE BY 2.09524 */

LAB EXERCISE 4

/* LAB EXERCISE 4.01 TO DETERMINE WHETHER THE INTEGER ENTERED BY THE USER IS ODD OR EVEN BY- VIKAS TOMAR XI-D*/

#include<iostream.h>

void main() { int n;

cout<<"ENTER AN INTEGER: "; cin>>n;

if (n%2==0) cout<<"\nTHE INTEGER IS EVEN."; else cout<<"\nTHE INTEGER IS ODD."; } /*OUTPUT:ENTER AN INTEGER:5 THE INTEGER IS ODD.*/

/* LAB EXERCISE 4.02 TO DETERMINE TO DETERMINE THE ABSOLUTE VALUE OF A NUMBER BY- VIKAS TOMAR XI-D*/

#include<iostream.h> void main()

{int n;

cout<<"ENTER A NUMBER (+ve or -ve): " ; cin>>n; if (n>0) cout<<"\nABSOLUTE VALUE OF THE NUMBER= "<<n; else cout<<"\nABLOLUTE VALUE OF THE NUMBER= "<<-(n); } /*OUTPUT:ENTER A NUMBER (+ve or -ve): -7 ABSOLUTE VALUE OF THE NUMBER= 7 */

/*LAB EXERCISE 4.3 TO FIND THE TOTAL EXPENSE WHEN THREE DIFFERENT ITEMS Vikas Tomar XI-D*/ #include<iostream.h> void main() {int i1,i2,i3,n1,n2,n3; cout<<"ENTER COST OF ITEM 1 cin>>i1; cout<<"ENTER THE QUANTITY OF ITEM 1: "; cin>>n1; cout<<"\nENTER COST OF ITEM 2 cin>>i2; cout<<"ENTER THE QUANTITY OF ITEM 2: "; cin>>n2; cout<<"\nENTER COST OF ITEM 3 cin>>i3; cout<<"ENTER THE QUANTITY OF ITEM 3: "; cin>>n3; cout<<"\nTOTAL COST: Rs. "<<i1*n1+i2*n2+i3*n3; } : Rs. "; : Rs. "; : Rs. ";

/*OUTPUT:ENTER COST OF ITEM 1 : Rs. 25

ENTER THE QUANTITY OF ITEM 1: 4

ENTER COST OF ITEM 2

: Rs. 50

ENTER THE QUANTITY OF ITEM 2: 4

ENTER COST OF ITEM 3

: Rs. 10

ENTER THE QUANTITY OF ITEM 3: 5

TOTAL COST: Rs. 350 */

/*LAB EXERCISE 4.4 TO FIND PROFIT OR LOSS BY VIKAS TOMAR XI-D*/

#include<iostream.h> void main() { float s,c;

cout<<"ENTER COST PRICE cin>>c;

: Rs.";

cout<<"ENTER SELLING PRICE: Rs."; cin>>s;

if (s>c) cout<<"\nYOU'VE MADE A PROFIT OF Rs."<<s-c<<" i.e."<<(s-c)*100/c<<"%";

else if (c==s) cout<<"\nNO PROFIT NO LOSS" ; else cout<<"\nYOU'VE MADE A LOSS OF Rs."<<c-s<<" i.e. "<<(c-s)*100/c<<"%";

/*OUTPUT:ENTER COST PRICE : Rs.1000

ENTER SELLING PRICE: Rs.1500

YOU'VE MADE A PROFIT OF Rs.500 i.e.50%

ENTER COST PRICE

: Rs.1000

ENTER SELLING PRICE: Rs.500

YOU'VE MADE A LOSS OF Rs.500 i.e. 50%

*/

/*LAB EXERCISE 4.5 TO FIND YOUNGEST AMONG RAM, SULABH AND AJAY BY VIKAS TOMAR XI-D*/

#include<iostream.h> void main() {int a,r,s; cout<<"ENTER THE AGE OF AJAY cin>>a; cout<<"ENTER THE AGE OF RAM cin>>r; cout<<"ENTER THE AGE OF SULABH: "; : "; : ";

cin>>s;

if ((a<r)&&(a<s)) cout<<"AJAY IS THE YOUNGEST AMONGST THE THREE."; else if ((r<a)&&(r<s)) cout<<"RAM IS THE YOUNGEST AMONG THE THREE."; else ((s<a)&&(s<r)) cout<<"SULABH IS THE YOUNGEST AMONG THE THREE."; } .

/* LAB EXERCISE 4.6 TO DETERMINE WHETHER THE ANGLES ENTERED BY THE USER FORM A TRIANGLE OR NOT BY- VIKAS TOMAR XI-D*/

#include<iostream.h> void main() { int a, b ,c;

cout<<"ENTER THE VALUE OF ANGLE A : "; cin>>a; cout<<"\nENTER THE VALUE OF ANGLE B : "; cin>>b; cout<<"\nENTER THE VALUE OF ANGLE C : "; cin>>c;

if (a+b+c==180) cout<<"\nTHE GIVEN ANGLES FORM A TRIANGLE."; else cout<<"\nTHE GIVEN ANGLES DO NOT FORM A TRIANGLE.";

} /*OUTPUT:ENTER THE VALUE OF ANGLE A : 45 ENTER THE VALUE OF ANGLE B : 45 ENTER THE VALUE OF ANGLE C : 90 THE GIVEN ANGLES FORM A TRIANGLE. */

/* LAB EXERCISE 4.7 TO DETERMINE WHETHER THE YEAR ENTERED BY THE USER LEAP YEAR OR NOT BY- VIKAS TOMAR XI-D*/

#include<iostream.h> void main() {int y; cout<<"ENTER THE YEAR: "; cin>>y; if (y%100==0) {if (y%400==0) cout<<"\nIT IS A LEAP YEAR"; else cout<<"\nIT IS NOT A LEAP YEAR.";} else if (y%4==0) cout<<"\nIT IS A LEAP YEAR!!"; else cout<<"\nIT IS NOT A LEAP YEAR";}

/*OUTPUT:ENTER THE YEAR: 2004 IT IS A LEAP YEAR!!

ENTER THE YEAR: 1900

IT IS NOT A LEAP YEAR.*/

/*LAB EXERCISE 4.8 TO CALCULATE THE GROSS SALARY OF AN EMPLOYEE Vikas Tomar XI-D*/ #include<iostream.h> void main() {float s,h1,d2,d1; cout<<"ENTER YOUR SALARY cin>>s; h1=10.0*s/100.0; d1=(90.0*s)/100.0; d2=(98.0/100.0)*s; if (s<=1500) {cout<<"HRA GIVEN TO YOU : Rs."<<h1; : Rs.";

cout<<"\nDA GIVEN TO YOU

: Rs."<<d1;

cout<<"\nYOUR GROSS SALARY } else {cout<<"HRA GIVEN TO YOU cout<<"\nDA GIVEN TO YOU cout<<"\nYOUR GROSS SALARY } } /*OUTPUT:ENTER YOUR SALARY HRA GIVEN TO YOU DA GIVEN TO YOU YOUR GROSS SALARY */ : Rs.2000 : Rs.500 : Rs.1960 : Rs.4460

: Rs."<<s+h1+d1;

: Rs.500"; : Rs."<<d2; : Rs."<<s+500+d2;

/*LAB EXERCISE 4.9 TO CALCULATE THE MONTHLY TELEPHONE BILL By-VIKAS TOMAR XI-D*/

#include<iostream.h>

void main() {int n; cout<<"ENTER THE NUMBER OF CALL: "; cin>>n; if (n<=100) cout<<"YOUR BILL: Rs.200"; else if (n<=150) cout<<"YOUR BILL: Rs."<<200+(0.60*(n-100)); else if (n<=200) cout<<"YOUR BILL: Rs."<<230+(0.50*(n-150)); else cout<<"YOUR BILL: Rs."<<255+(0.40*(n-200)); } /*OUTPUT:ENTER THE NUMBER OF CALL: 175 YOUR BILL: Rs.242.5 */

/*LAB EXERCISE 4.10 TO FIND THE ROOTS OF A QUARATIC EQUATION BY- VIKAS TOMAR XI-D*/

#include<iostream.h> #include<math.h>

void main() {int a,b,c; float D; cout<<"ENTER COEFFICIENT OF x^2 : "; cin>>a; cout<<"ENTER COEFFICIENT OF x cin>>b; cout<<"ENTER THE VALUE OF CONSTANT : "; cin>>c; : ";

D=(b*b)-(4*a*c);

if (D>0) {cout<<"\nREAL AND DISTINCT ROOTS"; cout<<"\nFIRST ROOT= "<<-b+sqrt(D)/2*a; cout<<"\nSECOND ROOT= "<<(-b-sqrt(D))/2*a; } else if (D==0) {cout<<"\n\nREAL AND EQUAL ROOTS"; cout<<"\nFIRST ROOT=SECOND ROOT= "<<-b/(2*a); } else cout<<"\nNO REAL ROOTS EXIST";

} /*OUTPUT:ENTER COEFFICIENT OF x^2: 1 ENTER COEFFICIENT OF x : 0

ENTER THE VALUE OF CONSTANT: -9 REAL AND DISTINCT ROOTS FIRST ROOT= 3 SECOND ROOT= -3

ENTER THE COEFFICIENT OF x^2: 1 ENTER THE COEFFICIENT OF x: 6 ENTER THE VALUE OF CONSTANT: 9 REAL AND EQUAL ROOTS EXIST ROOT1=ROOT2= -3

ENTER THE COEFFICIENT OF x^2: 1 ENTER THE COEFFICIENT OF x: 0 ENTER THE VALUE OF CONSTANT: 4 NO REAL ROOTS EXIST

/* LAB EXERCISE 4.11 TO CALCULATE THE DIVISION OBTAINED BY THE STUDENTS BY- VIKAS TOMAR XI-D*/

#include<iostream.h> void main() { int a,b,c,d,e; cout<<"\nENTER YOUR MARKS (OUT OF 100) FOR THE FOLLOWING SUBJECT:-"; cout<<"\n\nPHYSICS cin>>a; cout<<"\nCHEMESTRY cin>>b; cout<<"\nMATHEMATICS cin>>c; cout<<"\nENGLISH cin>>d; cout<<"\nCOMPUTER Sc. : "; cin>>e; : "; : "; : "; : ";

float p=((a+b+c+d+e)/500.0)*100;

cout<<"\n\nYOUR PERCENTAGE= "<<p<<"%";

if (p>=60) cout<<"\n\nCONGRAGTS!! YOU'VE GOT FIRST DIVISION"; else if ((p<60)&&(p>=50)) cout<<"\n\nWELL DONE!! YOU'VE GOT SECOND DIVISION"; else if ((p<50)&&(p>=40)) cout<<"\n\nYOU'VE GOT THIRD DIVISION"; else {cout<<"\n\nYOU'VE FAILED. BETTER LUCK NEXT TIME";} } /*OUTPUT:ENTER YOUR MARKS (OUT OF 100) FOR THE FOLLOWING SUBJECT:PHYSICS CHEMESTRY MATHEMATICS ENGLISH : 99 : 98 : 100 : 96

COMPUTER Sc. : 100 YOUR PERCENTAGE= 98.6% CONGRAGTS!! YOU'VE GOT FIRST DIVISION */

/*LAB EXERCISE 4.12 TO GET THE ASCII VALUE OF THE TERM ENTERED ENTERED BY TH USER By-VIKAS TOMAR XI-D*/

#include<iostream.h> void main() {char a; cout << "ENTER A CHARACTER: ";

cin >>a; cout << "ITS ASCII VALUE IS: " <<(int) a; if ((a>=65)&&(a<=90)) cout<<"\nIT IS A CAPITAL LETTER."; else if ((a>=97)&&(a<=122)) cout<<"\nIT IS A SMALL CASE LETTER."; else if ((a>=48)&&(a<=57)) cout<<"\nIT IS A DIGIT."; else cout<<"\nIT IS A SPECIAL CHARACTER.";} /*OUTPUT:ENTER A CHARACTER: V ITS ASCII VALUE IS: 86 IT IS A CAPITAL LETTER. ENTER A CHARACTER: v ITS ASCII VALUE IS: 118 IT IS A SMALL CASE LETTER. ENTER A CHARACTER: ! ITS ASCII VALUE IS: 33 IT IS A SPECIAL CHARACTER.

ENTER A CHARACTER: 5 ITS ASCII VALUE IS: 53 IT IS A DIGIT.*/

LAB EXERCISE 5
/* LAB EXERCISE 5.1 TO DISPLAY NAME OF THE DAY WHEN USER ENTERS THE DAY AS A DIGIT.

BY- VIKAS TOMAR XI-D*/ #include<iostream.h> void main() {int d; cout<<"ENTER A DIGIT (1-7): "; cin>>d; switch (d) {case 1: cout<<"\nSUNDAY"; break; case 2: cout<<"\nMONDAY"; break; case 3: cout<<"\nTUESDAY"; break; case 4: cout<<"\nWEDNESDAY"; break; case 5: cout<<"\nTHURSDAY"; break; case 6: cout<<"\nFRIDAY"; break; case 7: cout<<"\nSATURDAY"; break; default: cout<<"\nWRONG ENTRY"; }}

/*OUTPUT:ENTER A DIGIT (1-7): 4 WEDNESDAY ENTER A DIGIT (1-7): 2 MONDAY*/

/* LAB EXERCISE 5.2 TO DISPLAY NAME OF THE MONTH WHEN USER ENTERS THE DAY AS A DIGIT.

BY- VIKAS TOMAR XI-D*/

#include<iostream.h> void main() {int m; cout<<"ENTER A DIGIT (1-12): "; cin>>m; switch (m) {case 1: cout<<"\nJANUARY"; break; case 2: cout<<"\nFEBUARY"; break; case 3: cout<<"\nMARCH"; break; case 4: cout<<"\nAPRIL"; break; case 5: cout<<"\nMAY"; break; case 6: cout<<"\nJUNE"; break; case 7: cout<<"\nJULY"; break; case 8: cout<<"\nAUGUST"; break; case 9: cout<<"\nSEPTEMBER"; break; case 10: cout<<"\nOCTOBER"; break; case 11: cout<<"\nNOVEMBER"; break;

case 12: cout<<"\nDECEMBER"; break;

default: cout<<"\nWRONG ENTRY"; }} /*OUTPUT:ENTER A DIGIT (1-12): 7 JULY ENTER A DIGIT (1-12): 1 JANUARY */

/* LAB EXERCISE 5.3 TO DISPLAY THE QUADRANT OF THE ANGLE ENTERED BY THE USER. BY- VIKAS TOMAR XI-D*/

#include<iostream.h> void main() {int a,x; cout<<"ENTER ANY ANGLE : "; cin>>a; x=a%90; a= ((a%360)/90)+1;

if (x!=0) {switch (a) {case 1: cout<<"\nTHE ANGLE LIES IN FIRST QUADRANT."; break; case 2: cout<<"\nTHE ANGLE LIES IN SECOND QUADRANT."; break; case 3: cout<<"\nTHE ANGLE LIES IN THIRD QUADRANT."; break; case 4: cout<<"\nTHE ANGLE LIES IN FOURTH QUADRANT."; break; }}

else cout<<"\nTHE ANGLE LIES ON THE AXIS";}

/*OUTPUT;ENTER ANY ANGLE: 45 THE ANGLE LIES IN FIRST QUADRANT.

ENTER ANY ANGLE: 330 THE ANGLE LIES IN FOURTH QUADRANT.

ENTER ANY ANGLE: 270 THE ANGLE LIES ON THE AXIS */

/* LAB EXERCISE 5.4 TO CHECK WHETHER CHARACTER IS A DIGIT OR NOT BY- VIKAS TOMAR XI-D*/ #include<iostream.h> void main() {int c; cout<<"ENTER A CHARACTER: "; cin>>c; switch (c) {case 0: case 1: case 2: case 3: case 4: case 5: case 6: case 7: case 8:

case 9:cout<<"\nIT IS A DIGIT."; break; default: cout<<"\nIT IS NOT A DIGIT."; }}

/*OUTPUT:ENTER A CHARCTER: 4 IT IS A DIGIT.

ENTER A CHARCTER: F IT IS NOT A DIGIT. */

/* LAB EXERCISE 5.5 TO DISPLAY MENU OF SPORTS AND ASK THE USER TO ENTER HIS CHOICE AND DISPLAY IT BY- VIKAS TOMAR XI-D*/ #include<iostream.h> void main() {int c; cout<<"************CHOOSE YOUR FAVOURITE SPORTS FROM THE FOLLOWING*************"; cout<<"\n\n1.CRICKET"; cout<<"\n2.FOOTBALL"; cout<<"\n3.BASKETBALL"; cout<<"\n4.VOLLEYBALL"; cout<<"\n5.LAWN TENNIS"; cout<<"\n6.TABLE TENNIS"; cout<<"\n7.BADMINTON"; cout<<"\nENTER YOUR CHOICE: "; cin>>c; switch (c) {case 1:cout<<"\nYOUR CHOICE IS CRICKET."; break;

case 2:cout<<"\nYOUR CHOICE IS FOOTBALL."; break; case 3:cout<<"\nYOUR CHOICE IS BASKETBALL."; break; case 4:cout<<"\nYOUR CHOICE IS VOLLEYBALL."; break; case 5:cout<<"\nYOUR CHOICE IS LAWN TENNIS."; break; case 6:cout<<"\nYOUR CHOICE IS TABLE TENNIS."; break; case 7:cout<<"\nYOUR CHOICE IS BADMINTON."; break; default:cout<<"!!WRONG ENTRY!!"; }} /*OUTPUT:************CHOOSE YOUR FAVOURITE SPORTS FROM THE FOLLOWING*************

1.CRICKET 2.FOOTBALL 3.BASKETBALL 4.VOLLEYBALL 5.LAWN TENNIS 6.TABLE TENNIS 7.BADMINTON ENTER YOUR CHOICE: 1

YOUR CHOICE IS CRICKET.*/

LAB EXERCISE 6
(LOOPS)

/*LAB EXERCISE 6.1 WAP TO DISPLAY FIRST TEN NATURAL NUMBERS VIKAS TOMAR XI-D*/

#include<iostream.h> void main() {int i=1; while(i<=10) {cout<<i<<endl; i++;}}

/*OUTPUT :1 2 3 4 5 6 7 8 9 10 */

/*LAB EXERCISE 6.2 WAP TO FIND SUM OF FIRST 10 NATURAL NUMBERS VIKAS TOMAR XI-D*/

#include<iostream.h> void main() {int i=1,t=0;

while(i<10) {t+=i; cout<<i<<"+"; i++;} cout<<i<<" = "<<t+i; } /*OUTPUT :1+2+3+4+5+6+7+8+9+10 =55 */

/*LAB EXERCISE 6.3 WAP TO CALCULATE FACTORIAL OF A NUMBER VIKAS TOAMAR XI-D*/ #include<iostream.h> void main() {int i=1,k=1,n; cout<<"ENTER NUMBER: "; cin>>n; cout<<n<<"!= "; while(i<n) {k=k*i; cout<<i<<" x "; i++;} cout<<i<<" = "<<k*i; } /*OUTPUT:ENTER NUMBER: 6 6!= 1 x 2 x 3 x 4 x 5 x 6 = 720 */

/*LAB EXERCISE 6.4 WAP TO DISPLAY 'A' RAISE TO THE POWER 'B'

VIKAS TOMAR XI-D*/

#include<iostream.h> void main() {unsigned long a,b,i=1,k=1; cout<<"ENTRY A: "; cin>>a; cout<<"ENTRY B: "; cin>>b; cout<<"\nA^B="<<a<<"^"<<b<<" = "; while (i<b) {k*=a; cout<<a<<"x"; i++;} cout<<a<<" = "<<k*a;}

/*OUTPUT:ENTRY A: 4 ENTRY B: 5

A^B=4^5 = 4x4x4x4x4 = 1024 */

/*LAB EXERCISE 6.5 WAP TO REVERSE ANY POSITIVE INTEGER ENTERED BY THE USER VIKAS TOMAR XI-D*/ #include<iostream.h> void main() {unsigned long n,ld,rev=0; cout<<"ENTRY: "; cin>>n; while(n>0)

{ld=n%10; n=n/10; rev=(rev*10)+ld;} cout<<"REVERSE= "<<rev; } /*OUTPUT:ENTRY: 8456 REVERSE= 6548 */

/*LAB EXERCISE 6.6 WAP TO FIND THE SUM OF DIGITS OF ANY POSITIVE INTEGER ENTERED BY THE USER VIKAS TOMAR XI-D*/ #include<iostream.h> void main() {unsigned long n,ld,sum=0; cout<<"ENTRY: "; cin>>n; while(n>0) {ld=n%10; n=n/10; sum=sum+ld;} cout<<"SUM= "<<sum; } /*OUTPUT:ENTRY: 123456789 SUM= 45*/

/*LAB EXERCISE 6.7 WAP TO CHECK WHETHER A NUMBER IS PRIME OR NOT VIKAS TOAMR XI-D*/ #include<iostream.h>

#include<process.h> void main() {int a,b,i=2; cout<<"ENTRY: "; cin>>a; while(i<a/2) {b=a%i; i++; if(b==0) {cout<<"\nNOT A PRIME NUMBER"; exit(0); }} cout<<"\nPRIME"; } /*OUTPUT:ENTRY: 8 NOT A PRIME NUMBER

ENTRY: 2 PRIME */

/*LAB EXERCISE 6.8 WAP TO FIND THE HCF OF TWO NUMBERS VIKAS TOMAR XI-D*/ #include<iostream.h> void main() {int dd, dv,rem,hcf; cout<<"ENTER FIRST NUMBER : "; cin>>dd; cout<<"ENTER SECOND NUMBER : "; cin>>dv; //dv: DIVISOR //dd: DIVIDEND

while(rem!=0) {rem=dd%dv; if(rem==0) hcf=dv; else {dd=dv; dv=rem;} cout<<"HCF is : "<<hcf;}} /*OUTPUT:ENTER FIRST NUMBER : 100 ENTER SECOND NUMBER : 12 HCF is : 4 */

/*LAB EXERCISE 6.9 WAP TO FIND ARMSTRONG NUMBERS BETWEEN 0 & 500 VIKAS TOMAR XI-D*/ #include<iostream.h> void main() {int a,b,c,i=500; cout<<"LIST OF ARMSTRONG NUMBERS BETWEEN 0 AND 500 ARE:-"<<endl<<endl; while(i>0) {a=i/100; b=(i%100)/10; c=i%10; {if (a*a*a+b*b*b+c*c*c==i) cout<<i<<endl; i--;}} } /*OUTPUT:LIST OF ARMSTRONG NUMBERS BETWEEN 0 AND 500 ARE:-

407 371 370 153 1 */

/*LAB EXERCISE 6.10 WAP TO DISPLAY THE FIBONACCI SERIES UPTO n DESIRED TERMS VIKAS TOMAR XI-D*/ #include<iostream.h> void main() {unsigned long a,i=1,n,n_2=0,n_1=1; cout<<"ENTER THE NUMBER OF TERMS: "; cin>>a; cout<<n_2<<","<<n_1<<","; do {n=n_1+n_2; cout<<n<<","; n_2=n_1; n_1=n; i++;} while(i<=a-2); cout<<".."; } /*OUTPUT:ENTER THE NUMBER OF TERMS: 10 0,1,1,2,3,5,8,13,21,34... */

/*LAB EXERCISE 6.11 WAP TO DISPLAY THE SUM OF THE FOLLOWING SERIES 1+1/2+1/3+1/4+.......+1/n VIKAS TOMAR XI-D*/ #include<iostream.h>

void main() { int i,n; float sum=0; cout<<"SERIES"; cout<<"\n1 + 1/2 + 1/3 + 1/4 +.......+ 1/n"; cout<<"\nEnter the value of n: "; cin>>n; for(i=1;i<=n;i++) {sum += 1.0/i;} cout<<"SUM : "<<sum;} /*OUTPUT:SERIES 1 + 1/2 + 1/3 + 1/4 +.......+ 1/n Enter the value of n: 5 SUM : 2.28333 */

/*LAB EXERCISE 6.12 WAP TO DISPLAY THE NATURAL LOGARITHM OF 2 VIKAS TOMAR XI-D*/ #include<iostream.h> void main() {int i,n,s=-1; float sum=0; cout<<"Enter the value of n: ";

cin>>n; for(i=1;i<=n;i++) {s=s*(-1); sum += s*1.0/i;} cout<<"LOG 2 : "<<sum;} /*OUTPUT:Enter the value of n: 10 LOG 2 : 0.645635 */

/*LAB EXERCISE 6.13 WAP TO DISPLAY FIND THE PRODUCT OF TWO NUMBERS VIKAS TOMAR XI-D*/ #include<iostream.h> void main() {unsigned long a,b,i=1,k=0; cout<<"ENTRY A: "; cin>>a; cout<<"ENTRY B: "; cin>>b; cout<<"\nAxB="<<a<<"x"<<b<<" = "; while (i<=b) {k+=a; i++;} cout<<k;}

/*OUTPUT:ENTRY A: 2 ENTRY B: 5

AxB=2x5 = 10 */

LAB EXERCISE 7
(NESTED LOOPS)

/*LAB EXERCISE 7.1(i) TO DISPLAY THE FOLLOWING PATTERN ********** ********** ********** ********** VIKAS TOMAR XI-D*/ #include<iostream.h> void main() {for(int k=1;k<=4;k++) {for(int j=1;j<=10;j++) cout<<"*"; cout<<endl;}}

/*LAB EXERCISE 7.1(ii) TO DISPLAY THE FOLLOWING PATTERN * ** *** **** ***** VIKAS TOMAR XI-D*/ #include<iostream.h> void main() {for(int k=1;k<=5;k++) {for(int j=1;j<=k;j++) cout<<"*"; cout<<endl;}}

/*LAB EXERCISE 7.1(iii) TO DISPLAY THE FOLLOWING PATTERN * ** *** **** ***** VIKAS TOMAR XI-D*/ #include<iostream.h> void main() {for(int i=5,k=1;k<=5;k++,i--) {for(int l=i;l>0;l--) cout<<" "; for(int j=1;j<=k;j++) cout<<"*"; cout<<endl;} } /*LAB EXERCISE 7.1(iv) TO DISPLAY THE FOLLOWING PATTERN * *** **** ******* ********* VIKAS TOMAR XI-D*/ #include<iostream.h> void main() {for(int i=5,k=1;k<=5;k++,i--) {for(int l=i;l>0;l--) cout<<" "; for(int j=1;j<2*k;j++) cout<<"*";cout<<endl;}}

/*LAB EXERCISE 7.1(v) TO DISPLAY THE FOLLOWING PATTERN 1 222 33333 4444444 555555555 VIKAS TOMAR XI-D*/ #include<iostream.h> void main() {for(int i=5,k=1;k<=5;k++,i--) {for(int l=i;l>0;l--) cout<<" "; for(int j=1;j<2*k;j++) cout<<k; cout<<endl;}}

/*LAB EXERCISE 7.1(vi) TO DISPLAY THE FOLLOWING PATTERN 1 212 32123 4321214 543212345 VIKAS TOMAR XI-D*/ #include<iostream.h> void main() {int n; cout<<"ENTRY(1-9): "; cin>>n; for (int i=1;i<=n;i++)

for(int j=n;j>i;j--)

cout<<" "; for(int l=i;(l>=1);l--) cout<<l; for(int a=2;(a<=i);a++) cout<<a; cout<<endl;}}

You might also like