Professional Documents
Culture Documents
UTKARS
H AGARWAL
XI – A1
1
This project could not be
completed without thanking those who encouraged
us and put up with our revisions and updating of
the project with patience and tolerance and this
endeavor has prepared us to take more innovative
and challenging projects in future.
First of all our sincere thanks
goes to our principal Mrs. Grace Jose who provided
us this opportunity.
After that our sincere thanks
goes to our computer teacher Mr. Manesh Sir who
provided us his guidance by which we will able to
make this project .
Finally we thank to all the noticed and unnoticed
thanks hand behind the project.
2
This is to certify that Utkarsh agarwal of
class XI – A1 has submitted the computer project
on c++. He has taken proper care shown utmost
sincerity in completion of this project.
I certify that this project is up to my
expectation and as per the guidelines issued by
CBSE.
I am fully satisfied with the project report.
3
Mr. Manesh sir
Mrs. Grace jose
Computer teacher
Principal
4
Q1. DRAW THE FOLLOWING STRUCTURE:-
121
12321
1234321
123454321
A.# include<iostream.h>
# include<conio.h>
void main()
clrscr();
int i,j;
for(i=1;i<=5;i++)
cout<<endl;
for(j=1;j<=5-i;j++)
5
{
cout<<" ";
for(j=1;j<=i;j++)
cout<<j;
for(j=i-1;j>=1;j--)
cout<<j;
getch();
6
Q2. DRAW THE FOLLOWING STRUCTURE:-
AB
ABC
ABCD
ABCDE
A.# include<iostream.h>
# include<conio.h>
void main()
clrscr();
char i,j;
int p=4,k;
for(i='A';i<='E';i++)
cout<<endl;
for(k=1;k<=p;k++)
7
cout<<" ";
for(j='A';j<=i;j++)
cout<<j<<" ";
for(j=i-1;j>='A';j--)
cout<<j<<" ";
p--;
getch();
8
Q3. DRAW THE FOLLOWING STRUCTURE:-
$ $
$ $
$ $
$ $
$$$$$
A.# include<iostream.h>
# include<conio.h>
void main()
clrscr();
int i,j;
for(i=1;i<=5;i++)
cout<<endl;
for(j=1;j<=i;j++)
if (j==1||j==i||i==5)
cout<<"$"<<" ";
9
else
cout<<" ";
} getch(); }
Q4. WAP IN C++TO ACCEPT A LINE OF STRING FROM THE USER &
DISPLAY TOTAL CAPITAL ALPHABETS , TOTAL SMALL ALPHABETS ,
TOTAL DIGITS , TOTAL SPACES , TOTAL SPECIAL CHARACTERS FROM
THE GIVEN STRING .
A.# include<iostream.h>
# include<conio.h>
# include<stdio.h>
void main()
clrscr();
char str[100];
gets(str);
int cl=0,sl=0,dg=0,sp=0,sch=0,i=0;
while(str[i]!='\0')
cl++;
sl++;
dg++;
10
else if(str[i]==' ')
sp++;
else
sch++;
i++;
getch();
11
Q5.WAP IN C++ TO ENTER A LINE FROM THE USER & DISPLAY TOTAL
WORDS IN THAT LINE.
A.# include<iostream.h>
# include<conio.h>
# include<stdio.h>
void main()
clrscr();
char ln[100];
gets(ln);
int i=0,ct=0;
while(ln[i]!='\0')
if(ln[i]==' ')
ct++;
i++;
getch();
12
Q6. WAP IN C++ TO ACCEPT A STRING FROM THE USER AND CHANGE
IT TO:-
A.# include<iostream.h>
# include<conio.h>
# include<stdio.h>
void main()
clrscr();
char str1[100],str2[20],t;
gets(str1);
int i,j,lst,k;
for(i=0;str1[i]!='\0';i++);
i--;
while(i>=0)
j=0;
str2[j]=str1[i];
13
j++;
i--;
str2[j]='\0';
lst=j-1;
k=0;
while(k<j/2)
t=str2[k];
str2[k]=str2[lst];
str2[lst]=t;
k++;
lst--;
cout<<str2<<" ";
i--;
getch();
14
Q7. WAP TO WRITE THR INITIALS OF NAME WITH ITS FULL SIRNAME.
A.# include<iostream.h>
# include<conio.h>
# include<stdio.h>
void main()
clrscr();
char nm[30];
gets(nm);
for(int l=0;nm[l]!='\0';l++);
cout<<nm[0]<<".";
for(int i=1;i<p;i++)
if(nm[i]==' ')
cout<<nm[i+1]<<".";
for(i=p+1;nm[i]!='\0';i++)
cout<<nm[i];
getch();
15
Q8. WAP IN C++ TO GENERATE THE FOLLOWING SERIES:-
0 1 1 2 3 5 8 ------------------100.
A.#include<iostream.h>
#include<conio.h>
void main()
clrscr();
int a=0,b=1,c;
cout<<a<<b;
c=a+b;
while(c<=100)
cout<<c;
a=b;
b=c;
c=a+b;
getch();
16
Q9. WAP IN C++ TO GENERATE THE FOLLOWING SERIES:-
0 1 1 2 4 7 13 ---------------100.
A.#include<iostream.h>
#include<conio.h>
void main()
clrscr();
int a=0,b=1,c=1,d;
cout<<a<<b<<c;
d=a+b+c;
while(d<=100)
cout<<d;
a=b;
b=c;
c=d;
d=a+b+c;
getch();
17
Q10. WAP TO DISPLAY ALL THE ARMSTRONG NO.S FROM 1 TO
200000.
A. # include<iostream.h>
# include<conio.h>
void main()
clrscr();
for(n=1;n<=200000;n++)
p=n;
s=0;
while(p>0)
r=p%10;
s=s+r*r*r;
p=p/10;
if (s==n)
cout<<n<<endl;
getch();
18
Q11. WAP IN C++ TO DISPLAY ALL PRIME NO.S FROM 1 TO 1000.
A. # include<iostream.h>
# include<conio.h>
void main()
clrscr();
int n,i,ct;
for(i=1;i<=1000;i++)
ct=0;
for(n=1;n<=i/2;n++)
if (i%n==0)
ct++;
if (ct==1)
cout<<i<<" ";
getch();
19
Q12. A RECURSIVE FUNCTION FACT ACCEPTS A NO. AS PARAMETER
& RETURN ITS FACTORIAL. WAP IN C++ TO ACCEPT A NO. & DISPLAY
ITS FACTORIAL.
A.# include<iostream.h>
# include<conio.h>
int fact(int);
void main()
int n,s;
cin>>n;
s=fact(n);
getch();
int fact(int x)
if(x>1)
return x*fact(x-1);
else
return 1;
20
Q13. WAP IN C++ TO ACCEPT A NO. & DISPLAY SUM OF
DIGITS,PRODUCT OF DIGITS & REVERSE OF NO.
A.#include<iostream.h>
#include<conio.h>
void main()
int n,r,s=0,x=0,y=1;
cin>>n;
while(n>0)
r=n%10;
s=s+r;
x=x*10 + r;
y=y*r;
n=n/10;
getch();
21
A.# include<iostream.h>
# include<conio.h>
void main()
clrscr();
int a[4][4],i,j,sumr,sumc;
for(i=0;i<4;i++)
for(j=0;j<4;j++)
cin>>a[i][j];
for(i=0;i<4;i++)
sumc=sumr=0;
for(j=0;j<4;j++)
sumr=sumr+a[i][j];
sumc=sumc+a[j][i];
} getch(); }
A.# include<iostream.h>
22
# include<conio.h>
void main()
clrscr();
int a[4][4],i,j,t;
for(i=0;i<4;i++)
for(j=0;j<4;j++)
cin>>a[i][j];
for(i=0;i<3;i++)
for(j=i+1;j<4;j++)
t=a[i][j];
a[i][j]=a[j][i];
a[j][i]=t;
for(i=0;i<4;i++)
cout<<"\n";
for(j=0;j<4;j++)
23
cout<<a[i][j]<<" ";
getch();
A.# include<iostream.h>
24
# include<conio.h>
int myfun(int x)
return(x*x*x);
return(x+y);
return((x+y+z)/3);
void main()
clrscr();
int a,b;
float c;
a=myfun(4);
b=myfun(4,7);
c=myfun(4,5,11);
getch();
25
Q17. A UDF ACCEPTS TWO SET OF DISTANCES IN FEET & INCHES
THROUGH OBJECT OF STRUCTURE DISTANCE IN FEET & INCHES AND
DISPLAY THE TOTAL DISTANCE IN FEET & INCHES. WAP TO SO.
A.#include<iostream.h>
#include<conio.h>
struct dist
26
int feet;
int inches;
};
void totdist(dist,dist);
void main()
clrscr();
dist a,b;
cin>>a.feet>>a.inches;
cin>>b.feet>>b.inches;
totdist(a,b);
getch();
dist z;
z.feet=x.feet + y.feet;
z.inches=x.inches + y.inches;
if(z.inches>=12)
z.feet=z.feet + z.feet/12;
z.inches=z.inches%12;
cout<<z.feet<<" "<<z.inches;
27
Q18. WAP IN C++ TO ACCEPT DETAILS OF ‘N’ STUDENTS FROM THE
USER USING ARRAY OF STRUCTURE SUCH AS ROOL NO. , NAME ,
TERM , %. SORT THE RECORDS TO REARRANGE THEM IN
DESCENDING ORDER OF % USING BUBBLE SORT TECHNIQUE.
A.#include<iostream.h>
#include<conio.h>
#include<stdio.h>
struct stud
28
int rn;
char nm[15];
char term[15];
float per;
};
void main()
stud s[50],t;
int n,i,j;
cin>>n;
for(i=0;i<n;i++)
cin>>s[i].rn;
gets(s[i].nm);
gets(s[i].term);
cin>>s[i].per;
for(i=0;i<n-1;i++)
for(j=n-1;j>i;j--)
if(s[j].per>s[j-1].per)
t=s[j];
29
s[j]=s[j-1];
s[j-1]=t;
cout<<"\n sorted";
for(i=0;i<n;i++)
getch();
A.# include<iostream.h>
# include<conio.h>
void main()
clrscr();
int a[100],n,i,p,max,j,t;
30
cout<<"\n size";
cin>>n;
for(i=0;i<n;i++)
cin>>a[i];
for(i=0;i<n-1;i++)
max=a[i];
p=i;
for(j=i+1;j<n;j++)
if(a[j]>max)
max=a[j];
p=j;
t=a[i];
a[i]=a[p];
a[p]=t;
for(i=0;i<n;i++)
cout<<endl<<a[i];
getch();
31
Q20. WAP IN C++ TO ACCEPT THE SIZE OF ARRAY & SORT THEM
USING INSERTION SORT TECHNIQUE.
A.# include<iostream.h>
# include<conio.h>
void main()
clrscr();
int a[100],i,num,n;
cout<<"size";
cin>>n;
32
for(i=0;i<n;i++)
cin>>a[i];
for(i=1;i<n;i++)
num=a[i];
for(int j=i-1;j>=0;j--)
if(a[j]>num)
a[j+1]=a[j];
else
break;
a[j+1]=num;
for(i=0;i<n;i++)
cout<<endl<<a[i];
getch();
33
34