VERY SHORT QUESTIONS-OE

Q1. What is the function of operators? What are arithmetic operators? Give their examples.

Q2. How is ‘unary+’ operator different from ‘+’ operator? How is ‘unary-‘ operator different from ‘-‘ operator?

Q3. What are binary operators? Give examples of arithmetic binary operators.

Q4. What does the modulus operator % do? What will be the result of 7.2%2.1 and 8%3?

Q5. What will be the result of a=5/3 if a is

Q6. Assuming the res starts with the value 25, what will the following code fragment print out?

cout<<res–;

cout<<++res;

Q7. What will be the value of j=–k+2k if k is 20 initially?

Q8. What will be the value of P=P* ++J where J is 22 and P=3 initially?

Q9. What will be the value of following, if j=5 initially?

  1. (5* ++j)%6
  2. (5* j++)%6

Q10. A relational operator

  1. Assigns one operand to another
  2. Yields a Boolean (logical) result
  3. Compares two operands
  4. Logically combines two operands

Q11. Write an expression that uses a relational operator to return true if the variable total is greater than or equal to final.

Q12. Given that i=4, j=5, k=4, what will be the result of following expressions?

  1. i<k
  2. i<j
  3. i<=k
  4. i==j
  5. i==k
  6. j>k
  7. j>=i
  8. j!=i
  9. j!=k
  10. j<=k

Q13. What will be the order of evaluation for following expressions?

  1. i+5 >= j-6
  2. s+10 < p-2+2q
  3. i<j<k>l>=n

Q14. What will be the result of the following if ans is 6 initially?

Q15. What could be the possible error resulting in the wrong behavior of the following code?

int r=-13,l=-12;

cout<<”Result =”<<r<fabs(l);

Q16. What is the function of logical operators? Write an expression involving a logical operator to test if marks are 55 and grade is ‘B’.

Q17. The && and || operators

  1. compares two numeric values
  2. combine two numeric values
  3. compare two Boolean values
  4. combine two Boolean values.

Q18. What is the order of evaluation in the following expressions:

  1. a>b || b<d?
  2. x==y && y<=m?
  3. a>b && b<c || c<!d+3?

Q19. What is the result of following expression?

a >= b && (a+b) > a

  1. a=3, b=0
  2. a=7, b=7?

Q20. What is the result of following expression if

  1. check = 3
  2. check = 0
  3. check = -3.

(!check).

Q21. Identify the order of evaluation in the following expression:

4*5+7*2-8%3+4&&4/2-1+4||2-4||2-4+6*2.

Q22. Write a statement that uses a conditional operator to set grant to 10 if speed is more than 68, and to 0 otherwise.

Q23. What will be the result of following expression if

  1. age = 25
  2. age = 65
  3. age = 85?

age>65?350:100.

Q24. What will be the result of the following expression if

  1. ans = 700, val = 300
  2. ans = 800, val = 700?

ans-val<500?150:50.

Q25. What will be the result of following expression if

ans-(val<500?150:50).

Q26. Write a statement to print the size of

  1. double type of your machine.
  2. a long variable result.

Q27. What is the result of the following expressions?

  1. y=(t=4,t+3);
  2. y=((t=4,t+3),(t-2,t*3))

Q28. What is an expression? How many types of expression does C++ support?

Q29. Given the following set of declarations:

char ch;

int i,j,k;

float a,b,c;

double p,q;

Which of the following are arithmetic expressions

  1. ch = 40
  2. i+j-k
  3. j%k
  4. a%b+c-i
  5. p+q/b>1

Q30. Using the declarations of previous question identifies the logical expressions in the following expressions:

  1. (a)
  2. (!a)
  3. a+b%c
  4. a&&!a
  5. a||!a

Q31. Write an equivalent C++ expression for the following expressions:

  1. ut + ½ ft2
  2. sin a + tan-1 a – e2x
  3. |a| + b >= |b| + a
  4. [3x +5y / 5x +3y – 8xy / 2yx]3/2
  5. e|2×2 – 4x|

Q32. What is type conversion? What is meant by implicit and explicit type conversion?

Q33. What is the process of type promotion? What is integral promotion?

Q34. What do you mean by type casting? What is type cast operator?

Q35. What will be the resultant type of the following expression if ch represents a char variable, i is an int variable, f1 is a float variable and db is a double variable?

ch – i + db / f1 – i * f1 + db / i.

Q36. What will be the resultant type of the following expression if f1 is a float variable and db is a double variable?

(int) (f1+db).

Q37. Construct logical expressions to represent the following conditions:

  1. ch is a lowercase character  (The ASCII range for lowercase characters is 97 – 122)
  2. a is odd but less than 57.

Q38. Construct logical expression to represent the following conditions:

  1. Either age is more than 70 or members are more than or equal to 8.
  2. grade is ‘B’ and exper is more than 3 years

Q39. If a = 50 and b = 4 then determine the result of the following:

  1. a + = b
  2. a % = b
  3. a – = b
  4. a/ = b
  5. a * = b
  6. cout<<100/9;
  7. float pi = 22/7; cout<<pi.

Q40. An arithmetic assignment operator combines the effect of what two operators?

Q41. Write a statement that uses an arithmetic assignment operator to subtract the value of variable ans by 17. Write the same statement without arithmetic assignment operator.

Q42. Which header file must be included in the program to make use of C++’s built-in mathematical functions?

%d bloggers like this: