100 MCQ Questions of C++ (Conditional Statement) C++ 2nd questions set || Programming || Computer Technology || Edu Verse BY Pratik || Code With Pratik

C++ MCQs

C++ Multiple Choice Questions

1. What will be the output of the following code?

#include <iostream>
using namespace std;

int main() {
    int x = 10;
    if (x > 5) cout << "Greater than 5" << endl;
    return 0;
}
    
Answer: A) Greater than 5

2. What is the result of the following code?

#include <iostream>
using namespace std;

int main() {
    int x = 4;
    if (x == 4) cout << "Equal to 4" << endl;
    return 0;
}
    
Answer: A) Equal to 4

3. How is an `else` statement used in C++?

Answer: A) It executes if the `if` condition is false.

4. What will be the output of the following code?

#include <iostream>
using namespace std;

int main() {
    int x = 3;
    if (x > 5) cout << "Greater than 5" << endl;
    else cout << "Not greater than 5" << endl;
    return 0;
}
    
Answer: A) Not greater than 5

5. What is the result of the following code?

#include <iostream>
using namespace std;

int main() {
    int x = 7;
    if (x % 2 == 0) cout << "Even" << endl;
    else cout << "Odd" << endl;
    return 0;
}
    
Answer: B) Odd

6. What is the output of the following code?

#include <iostream>
using namespace std;

int main() {
    int x = 5;
    int y = 10;
    if (x < y && x > 0) cout << "x is positive and less than y" << endl;
    return 0;
}
    
Answer: A) x is positive and less than y

7. What will be the output of the following code?

#include <iostream>
using namespace std;

int main() {
    int x = 6;
    if (x > 5) cout << "x is greater than 5" << endl;
    else if (x == 5) cout << "x is 5" << endl;
    else cout << "x is less than 5" << endl;
    return 0;
}
    
Answer: A) x is greater than 5

8. What will the following code print?

#include <iostream>
using namespace std;

int main() {
    int a = 15;
    if (a % 3 == 0 || a % 5 == 0) cout << "Divisible by 3 or 5" << endl;
    return 0;
}
    
Answer: A) Divisible by 3 or 5

9. What will be the output of the following code?

#include <iostream>
using namespace std;

int main() {
    int x = 10;
    if (x < 5) cout << "x is less than 5" << endl;
    else if (x < 15) cout << "x is between 5 and 15" << endl;
    else cout << "x is 15 or more" << endl;
    return 0;
}
    
Answer: A) x is between 5 and 15

10. How does the `switch` statement differ from `if-else` in C++?

Answer: A) `switch` is used for multiple discrete values, while `if-else` is for complex conditions.

11. What will the following code print?

#include <iostream>
using namespace std;

int main() {
    int a = 8;
    if (a % 2 == 0 && a > 5) cout << "Even and greater than 5" << endl;
    return 0;
}
    
Answer: A) Even and greater than 5

12. What will be the output of the following code?

#include <iostream>
using namespace std;

int main() {
    int x = 4;
    int y = 7;
    if (x > 3 || y < 5) cout << "Condition met" << endl;
    return 0;
}
    
Answer: A) Condition met

13. What is the output of the following code?

#include <iostream>
using namespace std;

int main() {
    int x = 10;
    int y = 10;
    if (x == y) cout << "Equal" << endl;
    return 0;
}
    
Answer: A) Equal

14. What will be the output of the following code?

#include <iostream>
using namespace std;

int main() {
    int x = 5;
    if (x > 10) cout << "Greater" << endl;
    else if (x > 0) cout << "Positive" << endl;
    return 0;
}
    
Answer: A) Positive

15. What will be the output of the following code?

#include <iostream>
using namespace std;

int main() {
    int x = 5;
    if (x != 5) cout << "Not 5" << endl;
    else cout << "Is 5" << endl;
    return 0;
}
    
Answer: A) Is 5

16. What is the result of the following code?

#include <iostream>
using namespace std;

int main() {
    int x = 8;
    if (x < 10 && x > 5) cout << "Between 6 and 9" << endl;
    return 0;
}
    
Answer: A) Between 6 and 9

17. What will be the output of the following code?

#include <iostream>
using namespace std;

int main() {
    int x = 10;
    if (x > 5) {
        if (x < 15) cout << "In range" << endl;
    }
    return 0;
}
    
Answer: A) In range

18. What will be the result of the following code?

#include <iostream>
using namespace std;

int main() {
    int x = 3;
    if (x == 3) {
        cout << "Three" << endl;
    } else if (x == 4) {
        cout << "Four" << endl;
    } else {
        cout << "Not Three or Four" << endl;
    }
    return 0;
}
    
Answer: A) Three

19. What will be the output of the following code?

#include <iostream>
using namespace std;

int main() {
    int x = 7;
    if (x % 2 == 1) cout << "Odd" << endl;
    else cout << "Even" << endl;
    return 0;
}
    
Answer: A) Odd

20. What will be the output of the following code?

#include <iostream>
using namespace std;

int main() {
    int x = 5;
    int y = 4;
    cout << x % y << endl;
    return 0;
}
    
Answer: A) 1

21. What is the output of the following code?

#include <iostream>
using namespace std;

int main() {
    int a = 12;
    if (a % 4 == 0) cout << "Divisible by 4" << endl;
    return 0;
}
    
Answer: A) Divisible by 4

22. What will be the output of the following code?

#include <iostream>
using namespace std;

int main() {
    int x = 15;
    if (x >= 10 && x < 20) cout << "In range" << endl;
    return 0;
}
    
Answer: A) In range

23. What will be the output of the following code?

#include <iostream>
using namespace std;

int main() {
    int x = 9;
    if (x % 2 == 0) cout << "Even" << endl;
    else cout << "Odd" << endl;
    return 0;
}
    
Answer: A) Odd

24. What will be the output of the following code?

#include <iostream>
using namespace std;

int main() {
    int x = 20;
    if (x < 10) cout << "Less than 10" << endl;
    else if (x < 20) cout << "Between 10 and 19" << endl;
    else cout << "20 or more" << endl;
    return 0;
}
    
Answer: A) 20 or more

25. What will be the output of the following code?

#include <iostream>
using namespace std;

int main() {
    int a = 7;
    int b = 5;
    if (a > b) cout << "a is greater than b" << endl;
    return 0;
}
    
Answer: A) a is greater than b

26. What will be the output of the following code?

#include <iostream>
using namespace std;

int main() {
    int x = 8;
    if (x % 4 == 0) cout << "Divisible by 4" << endl;
    else cout << "Not divisible by 4" << endl;
    return 0;
}
    
Answer: A) Divisible by 4

27. What is the result of the following code?

#include <iostream>
using namespace std;

int main() {
    int x = 5;
    int y = 2;
    cout << x / y << endl;
    return 0;
}
    
Answer: A) 2

28. What will be the output of the following code?

#include <iostream>
using namespace std;

int main() {
    int x = 5;
    if (x > 0) cout << "Positive" << endl;
    else cout << "Negative" << endl;
    return 0;
}
    
Answer: A) Positive

29. What is the output of the following code?

#include <iostream>
using namespace std;

int main() {
    int x = 4;
    if (x % 2 == 0) cout << "Even" << endl;
    else cout << "Odd" << endl;
    return 0;
}
    
Answer: A) Even

30. What will be the output of the following code?

#include <iostream>
using namespace std;

int main() {
    int x = 3;
    if (x > 0 && x < 5) cout << "In range" << endl;
    return 0;
}
    
Answer: A) In range

31. What will be the output of the following code?

#include <iostream>
using namespace std;

int main() {
    int x = 11;
    if (x > 10) cout << "Greater than 10" << endl;
    return 0;
}
    
Answer: A) Greater than 10

32. What will be the output of the following code?

#include <iostream>
using namespace std;

int main() {
    int x = 2;
    if (x != 2) cout << "Not 2" << endl;
    else cout << "Is 2" << endl;
    return 0;
}
    
Answer: A) Is 2

33. What will be the result of the following code?

#include <iostream>
using namespace std;

int main() {
    int x = 12;
    if (x % 2 == 0 && x < 15) cout << "Even and less than 15" << endl;
    return 0;
}
    
Answer: A) Even and less than 15

34. What will be the output of the following code?

#include <iostream>
using namespace std;

int main() {
    int x = 20;
    if (x < 30) {
        if (x > 10) cout << "Between 11 and 29" << endl;
    }
    return 0;
}
    
Answer: A) Between 11 and 29

35. What will be the output of the following code?

#include <iostream>
using namespace std;

int main() {
    int x = 7;
    if (x < 5 || x > 10) cout << "Out of range" << endl;
    else cout << "In range" << endl;
    return 0;
}
    
Answer: A) Out of range

36. What will be the output of the following code?

#include <iostream>
using namespace std;

int main() {
    int x = 10;
    if (x % 3 == 0) cout << "Divisible by 3" << endl;
    else cout << "Not divisible by 3" << endl;
    return 0;
}
    
Answer: A) Not divisible by 3

37. What will be the result of the following code?

#include <iostream>
using namespace std;

int main() {
    int x = 6;
    if (x % 2 == 0 && x % 3 == 0) cout << "Divisible by 2 and 3" << endl;
    return 0;
}
    
Answer: A) Divisible by 2 and 3

38. What is the result of the following code?

#include <iostream>
using namespace std;

int main() {
    int x = 15;
    if (x % 5 == 0) cout << "Divisible by 5" << endl;
    else cout << "Not divisible by 5" << endl;
    return 0;
}
    
Answer: A) Divisible by 5

39. What will be the output of the following code?

#include <iostream>
using namespace std;

int main() {
    int x = 10;
    if (x < 5) cout << "Less than 5" << endl;
    else if (x == 10) cout << "Equal to 10" << endl;
    else cout << "Other value" << endl;
    return 0;
}
    
Answer: A) Equal to 10

40. What will be the result of the following code?

#include <iostream>
using namespace std;

int main() {
    int x = 3;
    if (x < 2 || x > 5) cout << "Out of range" << endl;
    else cout << "In range" << endl;
    return 0;
}
    
Answer: A) In range

41. What will be the output of the following code?

#include <iostream>
using namespace std;

int main() {
    int x = -1;
    if (x < 0) cout << "Negative" << endl;
    else cout << "Positive" << endl;
    return 0;
}
    
Answer: A) Negative

42. What will be the result of the following code?

#include <iostream>
using namespace std;

int main() {
    int x = 25;
    if (x % 5 == 0) cout << "Divisible by 5" << endl;
    else cout << "Not divisible by 5" << endl;
    return 0;
}
    
Answer: A) Divisible by 5

43. What will be the output of the following code?

#include <iostream>
using namespace std;

int main() {
    int x = 14;
    if (x % 7 == 0) cout << "Divisible by 7" << endl;
    else cout << "Not divisible by 7" << endl;
    return 0;
}
    
Answer: A) Divisible by 7

44. What will be the output of the following code?

#include <iostream>
using namespace std;

int main() {
    int x = 9;
    if (x < 10) cout << "Less than 10" << endl;
    else if (x == 10) cout << "Equal to 10" << endl;
    else cout << "Greater than 10" << endl;
    return 0;
}
    
Answer: A) Less than 10

45. What will be the output of the following code?

#include <iostream>
using namespace std;

int main() {
    int x = 0;
    if (x == 0) cout << "Zero" << endl;
    else cout << "Non-zero" << endl;
    return 0;
}
    
Answer: A) Zero

46. What will be the result of the following code?

#include <iostream>
using namespace std;

int main() {
    int x = -5;
    if (x <= 0) cout << "Non-positive" << endl;
    else cout << "Positive" << endl;
    return 0;
}
    
Answer: A) Non-positive

47. What is the output of the following code?

#include <iostream>
using namespace std;

int main() {
    int x = 8;
    if (x % 2 == 1) cout << "Odd" << endl;
    else cout << "Even" << endl;
    return 0;
}
    
Answer: A) Even

48. What is the result of the following code?

#include <iostream>
using namespace std;

int main() {
    int x = 20;
    if (x % 4 == 0 && x % 5 == 0) cout << "Divisible by 4 and 5" << endl;
    else cout << "Not divisible by 4 and 5" << endl;
    return 0;
}
    
Answer: A) Divisible by 4 and 5

49. What will be the output of the following code?

#include <iostream>
using namespace std;

int main() {
    int x = 18;
    if (x > 20 || x < 10) cout << "Out of range" << endl;
    else cout << "In range" << endl;
    return 0;
}
    
Answer: B) In range

50. What will be the result of the following code?

#include <iostream>
using namespace std;

int main() {
    int x = 13;
    if (x % 2 == 1 && x % 3 == 0) cout << "Odd and divisible by 3" << endl;
    else cout << "Not odd and divisible by 3" << endl;
    return 0;
}
    
Answer: A) Not odd and divisible by 3

51. What will be the output of the following code?

#include <iostream>
using namespace std;

int main() {
    int x = 17;
    if (x > 15) cout << "Greater than 15" << endl;
    else cout << "15 or less" << endl;
    return 0;
}
    
Answer: A) Greater than 15

52. What will be the output of the following code?

#include <iostream>
using namespace std;

int main() {
    int x = 10;
    if (x > 5 && x < 15) cout << "In range" << endl;
    else cout << "Out of range" << endl;
    return 0;
}
    
Answer: A) In range

53. What will be the output of the following code?

#include <iostream>
using namespace std;

int main() {
    int x = 0;
    if (x > 0) cout << "Positive" << endl;
    else if (x < 0) cout << "Negative" << endl;
    else cout << "Zero" << endl;
    return 0;
}
    
Answer: A) Zero

54. What will be the output of the following code?

#include <iostream>
using namespace std;

int main() {
    int x = 15;
    if (x % 5 == 0 && x % 3 == 0) cout << "Divisible by 3 and 5" << endl;
    else cout << "Not divisible by 3 and 5" << endl;
    return 0;
}
    
Answer: A) Divisible by 3 and 5

55. What will be the output of the following code?

#include <iostream>
using namespace std;

int main() {
    int x = 25;
    if (x % 10 == 0) cout << "Divisible by 10" << endl;
    else cout << "Not divisible by 10" << endl;
    return 0;
}
    
Answer: A) Divisible by 10

56. What will be the result of the following code?

#include <iostream>
using namespace std;

int main() {
    int x = 7;
    if (x % 2 == 0) cout << "Even" << endl;
    else cout << "Odd" << endl;
    return 0;
}
    
Answer: A) Odd

57. What will be the result of the following code?

#include <iostream>
using namespace std;

int main() {
    int x = 0;
    if (x > 0 && x % 2 == 0) cout << "Positive even" << endl;
    else if (x < 0 && x % 2 == 0) cout << "Negative even" << endl;
    else if (x == 0) cout << "Zero" << endl;
    else cout << "Non-zero odd" << endl;
    return 0;
}
    
Answer: A) Zero

58. What will be the output of the following code?

#include <iostream>
using namespace std;

int main() {
    int x = 4;
    if (x % 2 == 0) cout << "Even" << endl;
    else cout << "Odd" << endl;
    return 0;
}
    
Answer: A) Even

59. What will be the result of the following code?

#include <iostream>
using namespace std;

int main() {
    int x = 30;
    if (x % 2 == 0 && x % 3 == 0 && x % 5 == 0) cout << "Divisible by 2, 3, and 5" << endl;
    else cout << "Not divisible by 2, 3, and 5" << endl;
    return 0;
}
    
Answer: A) Divisible by 2, 3, and 5

60. What will be the result of the following code?

#include <iostream>
using namespace std;

int main() {
    int x = 12;
    if (x % 4 == 0 || x % 6 == 0) cout << "Divisible by 4 or 6" << endl;
    else cout << "Not divisible by 4 or 6" << endl;
    return 0;
}
    
Answer: A) Divisible by 4 or 6

61. What will the following code print?

#include <iostream>
using namespace std;

int main() {
    int x = 8;
    if (x % 2 == 0 && x > 5) cout << "Even and greater than 5" << endl;
    else cout << "Other" << endl;
    return 0;
}
    
Answer: A) Even and greater than 5

62. What will be the output of the following code?

#include <iostream>
using namespace std;

int main() {
    int x = 9;
    if (x % 3 == 0 || x % 5 == 0) cout << "Divisible by 3 or 5" << endl;
    else cout << "Not divisible by 3 or 5" << endl;
    return 0;
}
    
Answer: A) Divisible by 3 or 5

63. What will the following code print?

#include <iostream>
using namespace std;

int main() {
    int x = 10;
    if (x > 5 && x < 15) cout << "In range" << endl;
    else cout << "Out of range" << endl;
    return 0;
}
    
Answer: A) In range

64. What will the output of the following code be?

#include <iostream>
using namespace std;

int main() {
    int x = 0;
    if (x == 0) cout << "Zero" << endl;
    else cout << "Non-zero" << endl;
    return 0;
}
    
Answer: A) Zero

65. What will be the output of the following code?

#include <iostream>
using namespace std;

int main() {
    int x = 3;
    if (x % 2 == 0 || x % 3 == 0) cout << "Divisible by 2 or 3" << endl;
    else cout << "Not divisible by 2 or 3" << endl;
    return 0;
}
    
Answer: A) Divisible by 2 or 3

66. What will be the output of the following code?

#include <iostream>
using namespace std;

int main() {
    int x = 25;
    if (x % 5 == 0 && x % 7 == 0) cout << "Divisible by 5 and 7" << endl;
    else cout << "Not divisible by 5 and 7" << endl;
    return 0;
}
    
Answer: A) Not divisible by 5 and 7

67. What will be the result of the following code?

#include <iostream>
using namespace std;

int main() {
    int x = 22;
    if (x % 2 == 0 && x > 20) cout << "Even and greater than 20" << endl;
    else cout << "Other" << endl;
    return 0;
}
    
Answer: A) Even and greater than 20

68. What will be the result of the following code?

#include <iostream>
using namespace std;

int main() {
    int x = 45;
    if (x % 9 == 0 && x % 5 == 0) cout << "Divisible by 9 and 5" << endl;
    else cout << "Not divisible by 9 and 5" << endl;
    return 0;
}
    
Answer: A) Divisible by 9 and 5

69. What will be the output of the following code?

#include <iostream>
using namespace std;

int main() {
    int x = -1;
    if (x < 0) cout << "Negative" << endl;
    else if (x == 0) cout << "Zero" << endl;
    else cout << "Positive" << endl;
    return 0;
}
    
Answer: A) Negative

70. What will be the result of the following code?

#include <iostream>
using namespace std;

int main() {
    int x = 18;
    if (x % 3 == 0 && x % 4 != 0) cout << "Divisible by 3 but not 4" << endl;
    else cout << "Other" << endl;
    return 0;
}
    
Answer: A) Divisible by 3 but not 4

71. What will the output of the following code be?

#include <iostream>
using namespace std;

int main() {
    int x = 50;
    if (x % 2 == 0 && x % 5 == 0) cout << "Divisible by 2 and 5" << endl;
    else cout << "Not divisible by 2 and 5" << endl;
    return 0;
}
    
Answer: A) Divisible by 2 and 5

72. What will the result of the following code be?

#include <iostream>
using namespace std;

int main() {
    int x = 14;
    if (x % 7 == 0 || x % 2 == 0) cout << "Divisible by 7 or 2" << endl;
    else cout << "Not divisible by 7 or 2" << endl;
    return 0;
}
    
Answer: A) Divisible by 7 or 2

73. What will the output of the following code be?

#include <iostream>
using namespace std;

int main() {
    int x = 17;
    if (x % 2 == 0 && x % 5 == 0) cout << "Divisible by 2 and 5" << endl;
    else if (x % 2 == 0) cout << "Divisible by 2" << endl;
    else if (x % 5 == 0) cout << "Divisible by 5" << endl;
    else cout << "Not divisible by 2 or 5" << endl;
    return 0;
}
    
Answer: A) Not divisible by 2 or 5

74. What will the output of the following code be?

#include <iostream>
using namespace std;

int main() {
    int x = 6;
    if (x % 2 == 0 && x % 3 == 0) cout << "Divisible by 2 and 3" << endl;
    else if (x % 2 == 0) cout << "Divisible by 2" << endl;
    else if (x % 3 == 0) cout << "Divisible by 3" << endl;
    else cout << "Not divisible by 2 or 3" << endl;
    return 0;
}
    
Answer: A) Divisible by 2 and 3

75. What will be the result of the following code?

#include <iostream>
using namespace std;

int main() {
    int x = 21;
    if (x % 7 == 0 && x % 3 == 0) cout << "Divisible by 7 and 3" << endl;
    else cout << "Not divisible by 7 and 3" << endl;
    return 0;
}
    
Answer: A) Divisible by 7 and 3

76. What will the output of the following code be?

#include <iostream>
using namespace std;

int main() {
    int x = 8;
    if (x % 4 == 0 || x % 2 != 0) cout << "Divisible by 4 or not divisible by 2" << endl;
    else cout << "Other" << endl;
    return 0;
}
    
Answer: A) Divisible by 4 or not divisible by 2

77. What will be the output of the following code?

#include <iostream>
using namespace std;

int main() {
    int x = 30;
    if (x % 10 == 0 && x % 5 == 0) cout << "Divisible by 10 and 5" << endl;
    else cout << "Not divisible by 10 and 5" << endl;
    return 0;
}
    
Answer: A) Divisible by 10 and 5

78. What will be the result of the following code?

#include <iostream>
using namespace std;

int main() {
    int x = 11;
    if (x % 3 != 0 || x % 2 != 0) cout << "Not divisible by 3 or 2" << endl;
    else cout << "Divisible by 3 and 2" << endl;
    return 0;
}
    
Answer: A) Not divisible by 3 or 2

79. What will the output of the following code be?

#include <iostream>
using namespace std;

int main() {
    int x = 13;
    if (x % 2 == 0) cout << "Even" << endl;
    else if (x % 2 != 0) cout << "Odd" << endl;
    else cout << "Neither" << endl;
    return 0;
}
    
Answer: A) Odd

80. What will the result of the following code be?

#include <iostream>
using namespace std;

int main() {
    int x = 50;
    if (x % 4 == 0 && x % 5 == 0) cout << "Divisible by 4 and 5" << endl;
    else cout << "Not divisible by 4 and 5" << endl;
    return 0;
}
    
Answer: A) Divisible by 4 and 5

81. What will the output of the following code be?

#include <iostream>
using namespace std;

int main() {
    int x = 8;
    if (x % 2 == 0 && x % 4 == 0) cout << "Divisible by 2 and 4" << endl;
    else cout << "Not divisible by 2 and 4" << endl;
    return 0;
}
    
Answer: A) Divisible by 2 and 4

82. What will be the result of the following code?

#include <iostream>
using namespace std;

int main() {
    int x = 35;
    if (x % 7 == 0 && x % 5 != 0) cout << "Divisible by 7 but not 5" << endl;
    else cout << "Other" << endl;
    return 0;
}
    
Answer: A) Divisible by 7 but not 5

83. What will be the result of the following code?

#include <iostream>
using namespace std;

int main() {
    int x = 22;
    if (x % 2 == 0 || x % 5 == 0) cout << "Divisible by 2 or 5" << endl;
    else cout << "Not divisible by 2 or 5" << endl;
    return 0;
}
    
Answer: A) Divisible by 2 or 5

84. What will the output of the following code be?

#include <iostream>
using namespace std;

int main() {
    int x = 9;
    if (x % 3 == 0 && x % 2 == 0) cout << "Divisible by 3 and 2" << endl;
    else if (x % 3 == 0) cout << "Divisible by 3" << endl;
    else if (x % 2 == 0) cout << "Divisible by 2" << endl;
    else cout << "Not divisible by 3 or 2" << endl;
    return 0;
}
    
Answer: A) Divisible by 3

85. What will be the result of the following code?

#include <iostream>
using namespace std;

int main() {
    int x = 40;
    if (x % 8 == 0 || x % 5 == 0) cout << "Divisible by 8 or 5" << endl;
    else cout << "Not divisible by 8 or 5" << endl;
    return 0;
}
    
Answer: A) Divisible by 8 or 5

86. What will be the output of the following code?

#include <iostream>
using namespace std;

int main() {
    int x = 7;
    if (x % 2 != 0 && x % 7 == 0) cout << "Divisible by 7 but not by 2" << endl;
    else cout << "Not divisible by 7 or by 2" << endl;
    return 0;
}
    
Answer: A) Divisible by 7 but not by 2

87. What will be the result of the following code?

#include <iostream>
using namespace std;

int main() {
    int x = 12;
    if (x % 4 == 0 && x % 6 == 0) cout << "Divisible by 4 and 6" << endl;
    else cout << "Not divisible by 4 and 6" << endl;
    return 0;
}
    
Answer: A) Divisible by 4 and 6

88. What will the output of the following code be?

#include <iostream>
using namespace std;

int main() {
    int x = 10;
    if (x % 2 == 0 && x % 5 != 0) cout << "Divisible by 2 but not 5" << endl;
    else if (x % 5 == 0) cout << "Divisible by 5" << endl;
    else cout << "Not divisible by 2 or 5" << endl;
    return 0;
}
    
Answer: A) Divisible by 2 but not 5

89. What will the output of the following code be?

#include <iostream>
using namespace std;

int main() {
    int x = 25;
    if (x % 5 == 0 && x % 7 == 0) cout << "Divisible by 5 and 7" << endl;
    else cout << "Not divisible by 5 and 7" << endl;
    return 0;
}
    
Answer: A) Not divisible by 5 and 7

90. What will be the result of the following code?

#include <iostream>
using namespace std;

int main() {
    int x = 14;
    if (x % 7 == 0 && x % 3 != 0) cout << "Divisible by 7 but not by 3" << endl;
    else cout << "Other" << endl;
    return 0;
}
    
Answer: A) Divisible by 7 but not by 3

91. What will the output of the following code be?

#include <iostream>
using namespace std;

int main() {
    int x = 16;
    if (x % 4 == 0 && x % 8 != 0) cout << "Divisible by 4 but not by 8" << endl;
    else cout << "Other" << endl;
    return 0;
}
    
Answer: B) Other

92. What will the result of the following code be?

#include <iostream>
using namespace std;

int main() {
    int x = 18;
    if (x % 3 == 0 || x % 6 == 0) cout << "Divisible by 3 or 6" << endl;
    else cout << "Not divisible by 3 or 6" << endl;
    return 0;
}
    
Answer: A) Divisible by 3 or 6

93. What will be the output of the following code?

#include <iostream>
using namespace std;

int main() {
    int x = 45;
    if (x % 5 == 0 && x % 9 == 0) cout << "Divisible by 5 and 9" << endl;
    else cout << "Not divisible by 5 and 9" << endl;
    return 0;
}
    
Answer: A) Not divisible by 5 and 9

94. What will be the result of the following code?

#include <iostream>
using namespace std;

int main() {
    int x = 28;
    if (x % 4 == 0 && x % 7 == 0) cout << "Divisible by 4 and 7" << endl;
    else cout << "Not divisible by 4 and 7" << endl;
    return 0;
}
    
Answer: A) Divisible by 4 and 7

95. What will be the output of the following code?

#include <iostream>
using namespace std;

int main() {
    int x = 21;
    if (x % 3 == 0 && x % 7 == 0) cout << "Divisible by 3 and 7" << endl;
    else cout << "Not divisible by 3 and 7" << endl;
    return 0;
}
    
Answer: A) Divisible by 3 and 7

96. What will be the result of the following code?

#include <iostream>
using namespace std;

int main() {
    int x = 40;
    if (x % 8 == 0 && x % 5 == 0) cout << "Divisible by 8 and 5" << endl;
    else cout << "Not divisible by 8 and 5" << endl;
    return 0;
}
    
Answer: A) Divisible by 8 and 5

97. What will be the output of the following code?

#include <iostream>
using namespace std;

int main() {
    int x = 25;
    if (x % 2 == 0 && x % 5 == 0) cout << "Divisible by 2 and 5" << endl;
    else if (x % 2 == 0) cout << "Divisible by 2" << endl;
    else if (x % 5 == 0) cout << "Divisible by 5" << endl;
    else cout << "Not divisible by 2 or 5" << endl;
    return 0;
}
    
Answer: A) Divisible by 5

98. What will be the result of the following code?

#include <iostream>
using namespace std;

int main() {
    int x = 27;
    if (x % 3 == 0 && x % 9 != 0) cout << "Divisible by 3 but not by 9" << endl;
    else cout << "Other" << endl;
    return 0;
}
    
Answer: B) Other

99. What will be the output of the following code?

#include <iostream>
using namespace std;

int main() {
    int x = 18;
    if (x % 2 == 0 && x % 3 == 0) cout << "Divisible by 2 and 3" << endl;
    else cout << "Not divisible by 2 and 3" << endl;
    return 0;
}
    
Answer: A) Divisible by 2 and 3

100. What will be the result of the following code?

#include <iostream>
using namespace std;

int main() {
    int x = 30;
    if (x % 2 == 0 && x % 5 == 0) cout << "Divisible by 2 and 5" << endl;
    else if (x % 2 == 0) cout << "Divisible by 2" << endl;
    else if (x % 5 == 0) cout << "Divisible by 5" << endl;
    else cout << "Not divisible by 2 or 5" << endl;
    return 0;
}
    
Answer: A) Divisible by 2 and 5

Thank You for Visiting!

We are deeply grateful for your time and attention. Your engagement with our content means a lot to us, and we hope that the information provided has been valuable and insightful for your C++ journey.

We strive to create resources that empower and inspire. If you found our content useful, please consider sharing it with others who might benefit from it. Your support helps us continue to provide quality content and make a difference in the programming community.

If you have any feedback, suggestions, or questions, we’d love to hear from you. Feel free to reach out through our contact page or leave a comment. Together, let's continue to learn and grow in the fascinating world of C++ programming!

Thank you once again for your visit. Keep coding and stay curious!

Code With Pratik

My name is Pratik Patel. I am studen of Computer Science and Engineering. I have 2+ years of experience in graphic designing and web developing.

Post a Comment

Previous Post Next Post