- Get link
- X
- Other Apps
Write a program to print sum of two numbers
#include<iostream.h>
#include<conio.h>
int main()
{
clrscr();
int num1, num2, sum;
cout<<" Enter first number :";
cin>>num1;
cout<<" Enter second number :";
cin>>num2;
sum= num1+num2;
cout<<" The sum of given numbers is :";
cout<< sum;
}
Output
Enter first number : 4
Enter second number : 5
The sum of given numbers is : 9
Write a C++ program that inputs a student's marks in three subjects and prints the percentage marks.
#include<iostream.h>
#include<conio.h>
int main()
{
clrscr();
float sub1, sub2, sub3, marks, per;
cout<<"Enter marks obtained in 3 subjects : ";
cin>>sub1 >>sub2 >>sub3 ;
marks= sub1+sub2+sub3;
per=(marks/300)*100 ;
cout<<"\n "<<" The percentage marks are:" <<per << "%";
}
Output
Enter marks obtained in 3 subject : 50 75 80
The percentage marks are: 68.3
Write a program in C++ to accept three integers and print the largest of the three.
#include<iostream.h>
#include<conio.h>
int main()
{
clrscr();
int x,y,z,max;
cout<<" Enter three numbers :";
cin>>x>>y>>z;
max=x;
if( y>max)
max=y;
If(z>max)
max=z;
cout<<"\n The largest number is :";
cout<<max;
}
Output
Enter three numbers: 3 5 8
The largest number is: 8
Comments
Post a Comment