You are on page 1of 31

COMPUTER

SCIENCE
PRACTICAL FILE

YASHASHVI KALA/11-D 1 | P a g e
INDEX

S.NO PRACTICALS
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
YASHASHVI KALA/11-D 2 | P a g e
PRACTICAL-1
#include<iostream.h>

#include<conio.h>

void main()

clrscr();

int a,b,c;

cout<<"Enter 2 values\n";

cin>>a>>b;

c=a;

a=b;

b=c;

cout<<"a= "<<a<<" & b= "<<b;

getch();

YASHASHVI KALA/11-D 3 | P a g e
YASHASHVI KALA/11-D 4 | P a g e
PRACTICAL-2
#include<iostream.h>

#include<conio.h>

void main()

int a,b,c,max;

clrscr();

cout<<"Enter 3 no";

cin>>a>>b>>c;

max=a;

if(max<b&&max>c)

max=b;

cout<<max<<" is the greatest no.\n";

else if(max>b&&max<c)

max=c;

cout<<max<<" is the greatest no.\n";

else

cout<<max<<" is the greatest no.\n";

getch();

YASHASHVI KALA/11-D 5 | P a g e
YASHASHVI KALA/11-D 6 | P a g e
PRACTICAL-3
#include<iostream.h>

#include<conio.h>

void main ()

clrscr();

char ch;

cout<<"Enter a alphabet\n";

cin>>ch;

if(ch='a')

cout<<"it is a vowel\n";

else if(ch='e')

cout<<"it is a vowel\n";

else if(ch='i')

cout<<"it is a vowel\n";

else if(ch='o')

cout<<"it is a vowel\n";

else if (ch='u')

cout<<"it is a vowel\n";

else

cout<<"it is not a vowel\n";

getch();

YASHASHVI KALA/11-D 7 | P a g e
YASHASHVI KALA/11-D 8 | P a g e
PRACTICAL-4
#include<iostream.h>
#include<conio.h>
void main()
{

clrscr();

int n,n1=0,n2=1,n3;

cout<<"till how many terms should series work\n";

cin>>n;

cout<<"\n"<<n1<<" "<<n2<<" ";

int cntr=2;

for(;cntr<n;cntr++)

m3=n1+n2;

n1=n2;

n2=n3;

cout<<n3<<" ";

getch();

YASHASHVI KALA/11-D 9 | P a g e
YASHASHVI KALA/11-D 10 | P a g e
PRACTICAL-5
#include<iostream.h>

#include<conio.h>

#include<math.h>

void main()

clrscr();

int n;

cout<<"enter a no.\n";

cin>>n;

if(n<120)

cout<<pow(n,2)<<" is the square of "<<n;

else

cout<<"sorry no. is not allowed";

getch();

YASHASHVI KALA/11-D 11 | P a g e
YASHASHVI KALA/11-D 12 | P a g e
PRACTICAL-6
#include<iostream.h>

#include<conio.h>

#include<math.h>

void main()

clrscr();

float a,b,c,d,r1,r2;

cout<<"let ax^2+bx+c=0 be a quadratic equation\nEnter a,b,c";

cin>>a>>b>>c;

d=pow(b,2)-4*a*c

if(d<0)

cout<<"no roots of the equation\n";

if else(d==0)

r1=-b/(2*a);

cout<<"Equation has a single real root that= "<<r1;

else

r1=(-b+sqrt(d))/(2*a);

r2=(-b-sqrt(d))/(2*a);

YASHASHVI KALA/11-D 13 | P a g e
cout<<"Roots of equation are "<<r1<<" and "<<r2;

getch();

YASHASHVI KALA/11-D 14 | P a g e
PRACTICAL-7
#include<iostream.h>

#include<conio.h>

void main()

int i,n,sum=0;

float avg;

clrscr();

cout<<"enter the 10 number\n";

for (i=1;i<=10;i++)

{
cin>>n;

sum +=n;

avg=sum/10.0;

cout<<"The sum of 10 no ="<<sum<<"\nThe Average of = "<<avg;

getch();

YASHASHVI KALA/11-D 15 | P a g e
YASHASHVI KALA/11-D 16 | P a g e
PRACTICAL-8
#include<iostream.h>

#include<conio.h>

void main()

clrscr();

for (int i=1;i<=10;i++)

for(int j=1;j<=10;j++)
cout<<i<<"X"<<j<<"="<<i*j;
}
getch();
}

YASHASHVI KALA/11-D 17 | P a g e
YASHASHVI KALA/11-D 18 | P a g e
PRACTICAL-9
#include<iostream.h>

#include<conio.h>

void main()

clrscr();

for (char ch='A';ch<='Z';ch++)

cout<<ch<<"\n";

getch();

YASHASHVI KALA/11-D 19 | P a g e
YASHASHVI KALA/11-D 20 | P a g e
PRACTICAL-10
#include<iostream.h>
#include<conio.h>
#include<math.h>
void main
{
clrscr();
unsigned int num;
long double n,f=1;
cout<<"Enter a no.\n";
cin>>num;
n=sqrt(num);
for(int i=n;i>=1;i--)
{
f*=i;
}

cout<<"Factorial of square root of "<<num<<" i.e


"<<n<<" = "<<i;
getch();
}

YASHASHVI KALA/11-D 21 | P a g e
YASHASHVI KALA/11-D 22 | P a g e
PRACTICAL-11

#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
for(int i=1;i<=5;i++)
{
cout<<endl;
for(int k=1;k<=i;k++)
cout<<i;
}
getch();
}

YASHASHVI KALA/11-D 23 | P a g e
YASHASHVI KALA/11-D 24 | P a g e
PRACTICAL-12
#include<iostream.h>

#include<conio.h>

void main()

clrscr();

int a,b;

cout<<"Enter 2 no.";

cin>>a>>b;

a=a+b;

b=a-b;

a=a-b;

cout<<a<<b;

getch();
}

YASHASHVI KALA/11-D 25 | P a g e
YASHASHVI KALA/11-D 26 | P a g e
PRACTICAL-13
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int a,b,n;
cout<<"Enter 2 no.";
cin>>a>>b;
cout<<"Enter what you want to do\n";
cout<<"1.SUM\n2.DIFFERENCE\n";
cin>>n;
switch(n)
{
case 1:
n==1;
int sum;
sum=a+b;
cout<<sum;
break;
case 2:
n==2;
int diff;
diff=fabs(a-b);
cout<<diff;
break;
deafult :
cout<<"you choose wrong";
break;
getch();
}

YASHASHVI KALA/11-D 27 | P a g e
YASHASHVI KALA/11-D 28 | P a g e
PRACTICAL-14
#include<iostream.h>
#include<conio.h>
#include<math.h>
void main()
{
clrscr();
int num,digit,num1,sum=0;
cout<<"enter a no.\n";
cin>>num;
num1=num;
while(num>0)
{
digit=num%10;
sum+=pow(digit,3);
num=num/10;
}
if(num1==sum)
cout<<"it is an armstrong no."
else
cout<<"It isn't an armstrong no.";
getch();
}

YASHASHVI KALA/11-D 29 | P a g e
YASHASHVI KALA/11-D 30 | P a g e
PRACTICAL-15

YASHASHVI KALA/11-D 31 | P a g e

You might also like