Você está na página 1de 3

CLASSWORK APPLICATIONS FOR C++ DATA TYPES

Q1. Write a program to: -Define two float type variables; -Assign them to 3.45 and 1.245 -Calculate their multiplication and display the result.

Q2. Write a program to: -Define two short integer numbers; -Assign them to 12E7 and 36E8. -Find the summations of them. What is the problem in your program? Discuss!

Q3. Write a program to: -Declare two logical variables b1 and b2; -Assign them true and false respectively. -Display their values.

Q4. Write a program to: -Declare c1, c2, c3, c4 and c5 as char. -Assign them to M, E, 2, 4, 0 respectively. -Display ME240 using c1, c2, c3, c4 and c5.

Q5. Write the previous program using a single character string.

Q6. Write a program to input mass and height of an object from keyboard. Then calculate the potential energy of this object (Hint: Potential Energy = m*g*h).

Q7. Write a program that determines whether a given number is positive or negative.

Q8. Write a program that calculates the area of a rectangle. The width and height of the rectangle must be given using keyboard.

Q9. Write a program that calculates the area and circumference of a circle. The radius of circle must be given using keyboard.

Q10. Without using a computer, find the output the following program;

#include <iostream> using namespace std; int main(){ int a(5),b(8); cout<<"\ta=\t"<<a<<"--->b="<<b <<"--->\n"<<a+b<<endl; system ("pause"); }

Q11. Without using a computer, find the output the following program;
#include <iostream> using namespace std; int main(){ int a=5; { int a=7; { int a=12; cout<<"\t"<<2*a; } cout<<"\t"<<2*a; } cout<<"\t"<<2*a; system ("pause"); }

Você também pode gostar