CPP Imp Codes
CPP Imp Codes
CPP Imp Codes
#include <iostream>
Int main() {
If (num1 == num2) {
} else {
Return 0;
Q2
#include <iostream>
Int main() {
Int num;
If (num % 2 == 0) {
Cout << num << “ is an even integer”;
} else {
Return 0;
Q3
#include <iostream>
Int main() {
Int num;
If (num > 0) {
} else {
Return 0;
#include <iostream>
Int main() {
Int year;
} else {
Return 0;
Q5
#include <iostream>
Int main() {
Int age;
Cout << “Congratulation! You are eligible for casting your vote.”;
} else {
Return 0;
Q6
#include <iostream>
Int main() {
Int height;
} else {
Return 0;
}
Output: The person is Dwarf.
Q7
#include <iostream>
Int main() {
Cout << “1st Number = “ << num1 << “, 2nd Number = “ << num2 << “,\n”
<< “3rd Number = “ << num3 << “ The 1st Number is the greatest among three”;
Cout << “1st Number = “ << num1 << “, 2nd Number = “ << num2 << “,\n”
<< “3rd Number = “ << num3 << “ The 2nd Number is the greatest among three”;
} else {
Cout << “1st Number = “ << num1 << “, 2nd Number = “ << num2 << “,\n”
<< “3rd Number = “ << num3 << “ The 3rd Number is the greatest among three”;
Return 0;
Output: 3rd Number = 52 The 3rd Number is the greatest among three
Q8
#include <iostream>
If ((mathMarks >= 65 && phyMarks >= 55 && chemMarks >= 50 && totalMarks >= 190) ||
} else {
Return 0;
Q9
#include <iostream>
Int main() {
Int rollNo, physicsMarks, chemistryMarks, computerMarks;
String name;
Cout << “Input the marks of Physics, Chemistry, and Computer Application: “;
} else {
}
Return 0;
Marks in Physics: 70
Marks in Chemistry: 80
Percentage = 80.00
Division = First
Q10
#include <iostream>
Int main() {
Int temperature;
If (temperature < 0) {
} else {
Return 0;
Q11
#include <iostream>
Int main() {
Char character;
If (isalpha(character)) {
} else if (isdigit(character)) {
} else {
Return 0;
}
Output: This is a special character.
Q12
Q13
#include <iostream>
Int main() {
Char grade;
Switch (grade) {
Case ‘E’:
Break;
Case ‘V’:
Break;
Case ‘G’:
Break;
Case ‘A’:
Break;
Case ‘F’:
Cout << “Fail”;
Break;
Default:
Return 0;
Excellent
Q14
#include <iostream>
Int main() {
Int dayNumber;
Switch (dayNumber) {
Case 1:
Break;
Case 2:
Break;
Case 3:
Case 4:
Break;
Case 5:
Break;
Case 6:
Break;
Case 7:
Break;
Default:
Return 0;
Thursday
Q15
#include <iostream>
Int main() {
Int digit;
Switch (digit) {
Case 0:
Break;
Case 1:
Break;
Case 2:
Break;
Case 3:
Break;
Case 4:
Break;
Case 5:
Break;
Case 6:
Break;
Case 7:
Break;
Case 8:
Case 9:
Break;
Default:
Return 0;
Four
Send a message