0% found this document useful (0 votes)
79 views7 pages

C++ Programs Class 11

This document contains code snippets for several C++ programs that demonstrate concepts like: 1) Calculating the area and perimeter of a rectangle given length and breadth inputs. 2) Converting a decimal number to binary. 3) Calculating compound interest given principal, rate, time and number of years. 4) Finding the greatest number among three user inputs. 5) Solving quadratic equations and classifying the roots. 6) Determining if a number is an Armstrong number.

Uploaded by

Narun Bansal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
79 views7 pages

C++ Programs Class 11

This document contains code snippets for several C++ programs that demonstrate concepts like: 1) Calculating the area and perimeter of a rectangle given length and breadth inputs. 2) Converting a decimal number to binary. 3) Calculating compound interest given principal, rate, time and number of years. 4) Finding the greatest number among three user inputs. 5) Solving quadratic equations and classifying the roots. 6) Determining if a number is an Armstrong number.

Uploaded by

Narun Bansal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 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