Write a C++ program to take two integer inputs from user and print sum and product of them.
#include<iostream>intmain(){usingnamespacestd;intx;inty;cin>>x;//taking input for xcin>>y;//taking input for ycout<<x+y<<endl;cout<<x*y<<endl;return0;}
4.
Take two integer inputs from user. First calculate the sum of two then product of two. Finally, print the sum and product of both obtained results.
#include<iostream>intmain(){usingnamespacestd;intx;inty;cin>>x;//taking input for xcin>>y;//taking input for yintsum=x+y;intprod=x*y;cout<<sum+prod<<endl;cout<<sum*prod<<endl;return0;}
5.
Write a program to take input of length and breadth of a rectangle from the user and print its area.
#include<iostream>intmain(){usingnamespacestd;intlength;intbreadth;cout<<"Enter value of length"<<endl;cin>>length;cout<<"Enter value of breadth"<<endl;cin>>breadth;//taking input for yintarea=length*breadth;cout<<"Area is "<<area<<endl;return0;}
6.
Write a C++ program to print an int, a double and a char on screen.
#include<iostream>intmain(){usingnamespacestd;intx;doubley;charz;cout<<"Enter value of a int, double and a char"<<endl;cin>>x;cin>>y;cin>>z;cout<<"int is "<<x<<" double is "<<y<<" char is "<<z<<endl;return0;}
7.
Print the ASCII value of the character 'h'.
#include<iostream>intmain(){usingnamespacestd;cout<<"ASCII value of h is "<<(int)'h'<<endl;return0;}
8.
Write a program to assign a value of 100.235 to a double variable and then convert it to int.