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

COMPUTER

SCIENCE
C++
ASSIGNMENT FILE
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int len,bre,peri,area;
cout<<"Enter the length and the breadth;";
cin>>len>>bre;
area=len*bre;
peri=(2*len)+(2*bre);
cout<<"Area="<<area<<"\tperimeter="<<peri;
getch();
}
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int num;
int bin;
cout <<"Enter the number :";
cin >>num;
cout <<"The binary of "<<num<<" is ";
while(num>0)
{
bin=num%2;
cout << bin;
num/=2;
}
getch();
}
#include<iostream.h>
#include<conio.h>
#include<math.h>
void main()
{
clrscr();
float p;
float r;
float n;
float t;
float e;
cout <<"Please enter the principle amount ";
cin >>p;
cout <<"Please enter the rate of interest per annum ";
cin>>r;
cout <<"Please enter the number of years the money is invested for ";
cin>>n;
cout <<"Please enter the time ";
cin>>t;
cout <<"The Compound interest is Rs:"<< p*pow((1+r/n),n*t);
getch();
}
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int a;
int b;
int c;
cout <<"Please enter the first number ";
cin>>a;
cout <<"Please enter the second number ";
cin>>b;
cout <<"Please enter the third number ";
cin>>c;
{
if (a>c && a>b)
cout <<"The greatest number is "<<a;
else if (b>c && b>a)
cout <<"The greatest number is "<<b;
else if (c>a && c>b)
cout <<"The greatest number is "<<c;
}
getch();
}
#include<iostream.h>
#include<math.h>
#include<conio.h>
void main()
{float a,b,c,d,root1,root2;
cout<<"Enter value of a, b and c : ";
cin>>a>>b>>c;
d=b*b-4*a*c;
if(d==0)
{root1=(-b)/(2*a);
root2=root1;
cout<<"Roots are real & equal";
}
else if(d>0)
{root1=-(b+sqrt(d))/(2*a);
root2=-(b-sqrt(d))/(2*a);
cout<<"Roots are real & distinct";
}
else
{
root1=(-b)/(2*a);
root2=sqrt(-d)/(2*a);
cout<<"Roots are imaginary";
}
cout<<"\nRoot 1= "<<root1<<"\nRoot 2= "<<root2;
getch();
}
#include<iostream.h>
#include<conio.h>
void main()
{
int n,r,sum=0,temp;
cout<<"Enter the Number= ";
cin>>n;
temp=n;
while(n>0)
{
r=n%10;
sum=sum+(r*r*r);
n=n/10;
}
if(temp==sum)
cout<<"Armstrong Number."<<endl;
else
cout<<"Not Armstrong Number."<<endl;
getch();
}

You might also like