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?
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?
- (5* ++j)%6
- (5* j++)%6
Q10. A relational operator
- Assigns one operand to another
- Yields a Boolean (logical) result
- Compares two operands
- 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?
Q13. What will be the order of evaluation for following expressions?
- i+5 >= j-6
- s+10 < p-2+2q
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?
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
- compares two numeric values
- combine two numeric values
- compare two Boolean values
- combine two Boolean values.
Q18. What is the order of evaluation in the following expressions:
- a>b || b<d?
- x==y && y<=m?
- a>b && b<c || c<!d+3?
Q19. What is the result of following expression?
a >= b && (a+b) > a
- a=3, b=0
- a=7, b=7?
Q20. What is the result of following expression if
- check = 3
- check = 0
- check = -3.
Q21. Identify the order of evaluation in the following expression:
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
- age = 25
- age = 65
- age = 85?
Q24. What will be the result of the following expression if
- ans = 700, val = 300
- ans = 800, val = 700?
Q25. What will be the result of following expression if
Q26. Write a statement to print the size of
- double type of your machine.
- a long variable result.
Q27. What is the result of the following expressions?
Q28. What is an expression? How many types of expression does C++ support?
Q29. Given the following set of declarations:
Which of the following are arithmetic expressions
- ch = 40
Q30. Using the declarations of previous question identifies the logical expressions in the following expressions:
Q31. Write an equivalent C++ expression for the following expressions:
- ut + ½ ft2
- √sin a + tan-1 a – e2x
- |a| + b >= |b| + a
- [3x +5y / 5x +3y – 8xy / 2yx]3/2
- 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?
Q37. Construct logical expressions to represent the following conditions:
- ch is a lowercase character (The ASCII range for lowercase characters is 97 – 122)
- a is odd but less than 57.
Q38. Construct logical expression to represent the following conditions:
- Either age is more than 70 or members are more than or equal to 8.
- grade is ‘B’ and exper is more than 3 years
Q39. If a = 50 and b = 4 then determine the result of the following:
- a + = b
- a % = b
- a – = b
- a/ = b
- a * = b
- 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?