it manual
DESCRIPTION
ManualTRANSCRIPT
PROGRAM 1: A PROGRAM TO ENTER MARKS FOR 5 SUBJECTS AND PRINT THEIR AVERAGE & PERCENTAGE OF MARKS.
CODE:
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
double marks1,marks2,marks3,marks4,marks5;
double ave=0.0;
double percent=0.0;
cout<<"Enter the marks in the first subject.";
cin>>marks1;
cout<<"Enter the marks in the second subject.";
cin>>marks2;
cout<<"Enter the marks in the third subject.";
cin>>marks3;
cout<<"Enter the marks in the fourth subject.";
cin>>marks4;
cout<<"Enter the marks in the fifth subject.";
cin>>marks5;
double total=marks1+marks2+marks3+marks4+marks5;
ave=total/5;
percent=(total/500)*100;
cout<<"The average marks is "<<ave;
cout<<"\nThe percentage is "<<percent<<"%";
getch(); }
2 | P a g e
OUTPUT:
__________________________________________________________________________________
PROGRAM 2: WRITE A PROGRAM TO ENTER THE NUMBER OF DAYS AND CONVERT THEM TO NUMBER OF YEARS, MONTHS, WEEKS AND REMAINING DAYS.
CODE:
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int days=0;
int years,months,weeks;
int days2=0;
cout<<"Enter the total number of days.";
cin>>days;
years=days/365;
days=days%365;
months=days/30;
days=days%30;
weeks=days/7;
days2=days%7;
cout<<"NUMBER OF YEARS: "<<years<<"\n";
3 | P a g e
cout<<"NUMBER OF MONTHS: "<<months<<"\n";
cout<<"NUMBER OF WEEKS: "<<weeks<<"\n";
cout<<"NUMBER OF DAYS: "<<days2<<"\n";
getch();
}
OUTPUT:
__________________________________________________________________________________
PROGRAM 3: WRITE A PROGRAM TO INPUT MARKS AND
OUTPUT THE GRADES BASED ON THE FOLLOWING CRITERIA
MARKS>=90 GRADE A+MARKS<90 and MARKS>=80 GRADE AMARKS<80 and MARKS>=70 GRADE BMARKS<70 and MARKS>=60 GRADE CMARKS<60 NOT ELLIGIBLE
CODE:
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
double marks=0.0;
cout<<"Enter your marks out of 100";
cin>>marks;
4 | P a g e
if(marks>=90)
{ cout<<"GRADE A+"; }
else if((marks<90)&&(marks>=80))
{ cout<<"GRADE A"; }
else if((marks<80)&&(marks>=70))
{ cout<<"GRADE B"; }
else if((marks<70)&&(marks>=60))
{ cout<<"GRADE C"; }
else
{ cout<<"NOT ELIGIBLE"; }
getch();
}
OUTPUT:
__________________________________________________________________________________
PROGRAM 4: WRITE A PROGRAM TO ENTER TWO NUMBERS AND FIND THE GREATER NUMBER USING IF-ELSE
CODE:
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int num1;
cout<<"Enter first number";
cin>>num1;
5 | P a g e
int num2;
cout<<"Enter second number";
cin>>num2;
if(num1>num2)
{
cout<<"\nFirst number is greater.";
}
else
{
cout<<"\nSecond number is greater.";
}
getch();
}
OUTPUT:
__________________________________________________________________________________
PROGRAM 5: WRITE A PROGRAM TO FIND THE ROOTS OF A QUADRATIC EQUATION.
CODE:
#include<iostream.h>
#include<math.h>
#include<conio.h>
void main()
{
clrscr();
6 | P a g e
int a,b,c;
double root1,root2,d;
cout<<"Enter a,b,c";
cin>>a>>b>>c;
root1=0;
root2=0;
d=0;
if(a==0)
{
cout<<"a is equal to zero. Not a quadratic equation.";
}
else
{
d=(b*b)-(4*a*c);
if(d>0)
{
root1=(-b+sqrt(d))/(2*a);
root2=(-b-sqrt(d))/(2*a);
cout<<"\nThe first root is "<<root1;
cout<<"\nThe second root is "<<root2;
}
else if(d==0)
{
root1=(-b+sqrt(d))/(2*a);
cout<<"\nRoots are equal. Root is "<<root1;
}
else
{
7 | P a g e
cout<<"The roots are imaginary.";
}
}
getch();
}
OUTPUT:
__________________________________________________________________________________
PROGRAM 6: WRITE A PROGRAM TO DESIGN A CALCULATOR USING NESTED IF
CODE:
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
double num1=0.0;
double num2=0.0;
char choice;
cout<<"Enter the first number.";
cin>>num1;
cout<<"Enter the second number.";
cin>>num2;
cout<<"Enter the operator for the operation to be performed.";
8 | P a g e
cin>>choice;
if(choice=='+')
{
double sum=num1+num2;
cout<<"\nThe sum of the 2 numbers is "<<sum;
}
else if(choice=='-')
{
double diff=(num1>num2)?(num1-num2):(num2-num1);
cout<<"\nThe difference of the 2 numbers is "<<diff;
}
else if(choice=='*')
{
double product=num1*num2;
cout<<"\nThe product of the 2 numbers is "<<product;
}
else if(choice=='/')
{
double quotient=(num1>num2)?(num1/num2):(num2/num1);
cout<<"\nThe quotient of the 2 numbers is "<<quotient;
}
else
{
cout<<"\nINVALID INPUT";
}
getch();
}
9 | P a g e
OUTPUT:
__________________________________________________________________________________
PROGRAM 7: WRITE A PROGRAM TO DESIGN A CALCULATOR USING SWITCH CASE
CODE:
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
double num1=0.0;
double num2=0.0;
char choice;
cout<<"Enter the first number.";
cin>>num1;
cout<<"Enter the second number.";
cin>>num2;
cout<<"Enter the operator for the operation to be performed.";
cin>>choice;
switch(choice)
{
case '+':
{
double sum=num1+num2;
10 | P a g e
cout<<"\nThe sum is "<<sum;
break;
}
case '-':
{
double diff=(num1>num2)?(num1-num2):(num2-num1);
cout<<"\nThe difference is "<<diff;
break;
}
case '*':
{
double product=num1*num2;
cout<<"\nThe product is "<<product;
break;
}
case '/':
{
double quotient=(num1>num2)?(num1/num2):(num2/num1);
cout<<"\nThe quotient is "<<quotient;
break;
}
default:cout<<"Invalid operator.";
}
getch();
}
11 | P a g e
OUTPUT:
__________________________________________________________________________________
PROGRAM 8: WRITE A PROGRAM TO ENTER THE NUMBER OF A DAY AND PRINT ITS CORRESPONDING NAME.
CODE:
#include<iostream.h>
#include<conio.h>
void main()
{clrscr();
int day=0;
cout<<"Enter the number of days in a week";
cin>>day;
switch(day)
{
case 1:
{ cout<<"\nSUNDAY";
break;
}
case 2:
{cout<<"\nMONDAY";
break;
}
case 3:
12 | P a g e
{ 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<<"Invalid entry";
}
getch();
}
13 | P a g e
OUTPUT:
__________________________________________________________________________________
PROGRAM 9: WRITE A PROGRAM TO CALCULATE AREA OF TRIANGLE,CIRCLE OR RECTANGLE BASED ON USERS CHOICE
CODE:
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int choice=0;
cout<<"Enter your choice";
cout<<"\n\t 1 for area of the triangle";
cout<<"\n\t 2 for area of the circle";
cout<<"\n\t 3 for area of the rectangle";
cin>>choice;
switch(choice)
{
case 1:
{ double base, height;
cout<<"Enter the base measurement";
cin>>base;
cout<<"Enter the height measurement";
14 | P a g e
cin>>height;
double area1=(base*height)/2;
cout<<"the area of triangle is:"<<area1<<"sq.units";
break;
}
case 2:
{ double radius;
cout<<"Enter the radius measurement";
cin>>radius;
double area2=(22*radius*radius)/7;
cout<<"\nArea of circle is "<<area2<<"sq.units";
break;
}
case 3:
{
double length,breadth;
cout<<"\nEnter length measurement.";
cin>>length;
cout<<"\nEnter the breadth measurement.";
cin>>breadth;
double area3=length*breadth;
cout<<"\nArea of rectangle is "<<area3<<"sq.units";
break;
}
default:cout<<"\nInvalid entry";
}
getch();
}
15 | P a g e
OUTPUT:
__________________________________________________________________________________
PROGRAM 10: WRITE A PROGRAM TO ACCEPT A THREE DIGIT NUMBER FROM THE USER AND CHECK IF IT IS A PALINDROME
CODE:
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int num1=0;
cout<<"Enter a three digit number";
cin>>num1;
int sum=0;
int num=num1;
int digit3=num1%10;
num1=num1/10;
sum=(sum*10)+digit3;
int digit2=num1%10;
num1=num1/10;
sum=(sum*10)+digit2;
int digit1=num1%10;
16 | P a g e