Sunteți pe pagina 1din 4

Assignment 1

Introduction to C++
Q1. Define
a. TOKEN b. KEYWORD c. VARIABLE
d. CONSTANT e. PUNCTUATORS

Q2. What do you mean by data types?

Q3. Differentiate between fundamental and derived data types.

Q4. What are the ranges and how much memory the following data types require: -
a. short int b. int c. long int d. float
e. long double f. double g. long h. char
i. signed char j. unsigned char

Q5. Which of the following are the invalid statement: -
a. const int x = 5; b. int const x = 5;

Q6. What are the rules for declaring a variable?

Q7. How are the statements terminated in C++?

Q8. Some of the C++ statements are written incorrectly. Identify the error and give the
correct form: -
a. 5.34 b. +345 c. 0.57- d. 8.34E4

Q9. What is the difference between: - a, a and a?

Q10. What will be the size of the following constants: a and a

Q11. State why the following statements are invalid: -
a. age>70&& <90 b. 2+5=x;

Q12. Justify which statement is correct: -
a. C is superset of C++ b. C++ is superset of C

Q13. What do you mean by data hiding?

Q14. While naming a variable we cant start with: -
a. _ (underscore) b. number
c. None choose the correct option.

Q15. What are the different storage classes supported by C++ language.

Q16. Choose the valid variable names from the following: -
a. roll_no b. 19sep_score c. your age d. int
e. salary f. sep98_score g. cout h. MYAGE

Q17. We can declare a variable anywhere in the code. True/False (Justify)

Q18. Find the errors if any: -
a. int a=5; cout<<A; b. int a=5; int A=6; cout<<a+A;
c. int a=5; int a=6; cout<<a+a; d. int a=5; 5+1=a; cout<<a;

Q19. By default integer and character data types are signed/unsigned. (Justify)

Q20. Guess the output: -
a. int x=32768; b. int a=-32769; c. unsigned int x=32768;
cout<<x; cout<<x; cout<<x;
d. unsigned int x=-10; e. unsigned int x=65536;
cout<<x; cout<<x;

Q21. How you can provide alternative names for a data type?

Q22. Which one is the invalid statement: -
a. typedef int integer; b. typedef integer int;

Q23. Initialization at the compile time is known as static Initialization. However variables can
also be Initialized at the run time. Initialization of variables at the run time is known as
dynamic Initialization. Give an example of static and dynamic Initialization.

Q24. Justify whether the following statements are valid or not
a. sq= (num * num), cube = num*num*num);
cout<<sq<<cube;
b. x=(1+2, 3+4); cout<<x;
c. int x,y=1, z=2,m=3;
x=(y+=++z,m+=++z);
cout<<x<<y<<z;

Q25. Input the value of a,b and c of your choice so that the value of c will be assigned to
d. Remember the value of c should not be the largest. d=a>b?a>c?a:c:b>c?b:c;

Q26. Which one is the invalid statement? a. int x=y=z=5; b. x=y=z=5;

Q27. Guess the output and describe any one output
a. int x=5,y; y= x++ + x++ ; cout <<x<<y;
b. int x=5,y; y= x++ + ++x ; cout <<x<<y;
c. int x=5,y; y= ++x + ++x ; cout <<x<<y;
d. int x=5,y; y= x++ + ++x + x-- ; cout <<x<<y;
e. int x=5,y; y= ++x * ++x + --x ; cout <<x<<y;

Q28 Guess the output and describe any one output
a. int x=5; x= x++ + x++ ; cout <<x;
b. int x=5; x= x++ + ++x ; cout <<x;
c. int x=5; x= ++x + ++x ; cout <<x;
d. int x=5; x= x++ + ++x + x-- ; cout <<x;
e. int x=5; x= ++x * ++x + --x ; cout <<x;

Q29 Guess the output and describe any one output
a. int x=5; cout<<x++<<x++;
b. int x=5; cout<<++x<<++x;
c. int x=5; cout<<x++<<++x;
d. int x=5; cout<<++x<<x++;
e. int x=5; cout<<x++<<++x<<-- x <<x-- ;

Q30 Guess the output and describe any one output
a. int x=5; cout<<x++ + x++;
b. int x=5; cout<<x++ + ++x;
c. int x=5; cout<<++x + ++x;
d. int x=5; cout<<++x + x++;
e. int x=5; cout<<x++ + ++x + x--;

Q31 a. int x=10,y=2,z; b int x=10,y=2,z;
z=(x>y) && (y<5); z=(x>y) && (y>5);
cout<<z; cout<<z;
c. int x=10,y=2,z; d int x=10,y=2,z;
z=(x>y) (y<5); z=(x>y) (y>5);
cout<<z; cout<<z;
e. x=10; f. x=-10; g x=0; h x=10;
z=!x; z=!x; z=!x; x=!x;
cout<<z; cout<<z; cout<<z; cout<<x;

Q32. What is type conversion? What are different type conversion?. Give example.

Q33. Guess the output
a. cout<<5/3; b. cout<<5/3.0; c cout<<5.0/3;
d. cout<<5.0/3.0; e. cout<<5/ (float)3;

Q34. Differentiate between unary, binary and ternary operators. Give examples of each.

Q35. If a=5, b=10, c=15 and d=0 what are the truth value of these expression
a a!=7 b b<=a c. !(a>5) c<=a+b
d. a+d>=c-b e. d/a <c*b

Q36. Determine the order of evaluation of these expressions
a a*b*c- d/e *a b. a&& b (c>=d)

Q37. Given the value of a,b and c evaluate these expression (a>=b) (!(c==b) && (c<a))
a. a=10, b=5, c=11; b. a=10, b=10, c=10; c. a=9, b=10, c=2;

Q38. What is the output of the following programme
a. void main() b. void main()
{ {
int i,j,k,l; int v1=10,v2=20,v3=30,v4;
i=10; j=15; k=25; v4=!(v2<v1 && v3>v2);
l=!(k>j>i); v4? cout<< true: cout<< false;
(l)?cout<< true: cout<< false; }
}
Q39. What would be appropriate data type to store the following?
a) Length of the cloth b) Age of the student
c) An exclamation mark d) Radius of the circle

Q40. How comments can be added to a C++ program?

Q41. Give suitable complete declarations from the following: -
a) Height of a student of type float.
b) Integer variable: m = 0, n = 1, k.
c) Character variable ch initialized with value P.

Q42. Write a program to print the simple interest.

Q43. Write a program to print the area of triangle.

Q44. Take a number of three digits and then print the reverse of the number.

Q45. Take a number of three digits and then print the sum of the number.

S.K.Jha
(Faculty of Computer Science DAV)
Choose yr Goal, Move Steadily, Success is yrs
*****

S-ar putea să vă placă și