1 Crore+ students have signed up on EduRev. Have you? Download the App |
Which of the following is not a valid data type in C++?
Which of the following is true about the 'cin' object in C++?
What is the purpose of the 'namespace' keyword in C++?
Which of the following is true about the main() function in C++?
What is the output of the following code snippet?
#include <iostream>
int main() {
int x = 5;
int y = 10;
int z = x + y;
std::cout << "The value of z is: " << z << std::endl;
return 0;
}
What is the output of the following code snippet?
#include <iostream>
int main() {
int x = 5;
std::cout << "The value of x is: " << x << std::endl;
return 0;
}
What is the output of the following code snippet?
#include <iostream>
int main() {
int x = 10;
std::cout << x << " " << x++ << std::endl;
return 0;
}
What is the output of the following code snippet?
#include <iostream>
int main() {
int x = 5;
std::cout << x++ << " " << ++x << std::endl;
return 0;
}
What is the output of the following code snippet?
#include <iostream>
int main() {
int x = 10;
int y = 5;
std::cout << "The sum of x and y is: " << x + y << std::endl;
return 0;
}
What is the output of the following code snippet?
#include <iostream>
int main() {
int x = 10;
int y = 5;
std::cout << "The difference of x and y is: " << x - y << std::endl;
return 0;
}
What is the output of the following code snippet?
#include <iostream>
int main() {
int x = 10;
int y = 2;
std::cout << "The division of x and y is: " << x / y << std::endl;
return 0;
}
What is the output of the following code snippet?
#include <iostream>
int main() {
int x = 10;
int y = 3;
std::cout << "The remainder of x divided by y is: " << x % y << std::endl;
return 0;
}
What is the output of the following code snippet?
#include <iostream>
int main() {
int x = 5;
int y = 2;
int z = x * y;
std::cout << "The value of z is: " << z << std::endl;
return 0;
}
What is the output of the following code snippet?
#include <iostream>
int main() {
int x = 2;
int y = x + 3;
std::cout << "The value of y is: " << y << std::endl;
return 0;
}
What does the following code snippet output?
#include <iostream>
int main() {
int x = 10;
int y = 5;
if (x > y) {
std::cout << "x is greater than y";
} else {
std::cout << "x is less than or equal to y";
}
return 0;
}
What does the following code snippet output?
#include <iostream>
int main() {
int x = 10;
int y = 5;
if (x == y) {
std::cout << "x is equal to y";
} else if (x > y) {
std::cout << "x is greater than y";
} else {
std::cout << "x is less than y";
}
return 0;
}
What does the following code snippet output?
#include <iostream>
int main() {
int x = 10;
int y = 5;
int z = 7;
if (x > y && x > z) {
std::cout << "x is the largest";
} else if (y > x && y > z) {
std::cout << "y is the largest";
} else {
std::cout << "z is the largest";
}
return 0;
}
What does the following code snippet output?
#include <iostream>
int main() {
int x = 10;
int y = 5;
int z = 7;
if (x > y || x > z) {
std::cout << "x is greater than y or z";
} else {
std::cout << "x is less than or equal to y and z";
}
return 0;
}
What does the following code snippet output?
#include <iostream>
int main() {
int x = 10;
int y = 5;
int z = 7;
if (x > y && x > z) {
std::cout << "x is the largest";
} else if (y > z) {
std::cout << "y is the largest";
} else {
std::cout << "z is the largest";
}
return 0;
}
What does the following code snippet output?
#include <iostream>
int main() {
int x = 10;
int y = 5;
int z = 7;
int max = (x > y) ? ((x > z) ? x : z) : ((y > z) ? y : z);
std::cout << "The maximum value is: " << max;
return 0;
}
What does the following code snippet output?
#include <iostream>
int main() {
int x = 10;
int y = 5;
int z = 7;
int min = (x < y) ? ((x < z) ? x : z) : ((y < z) ? y : z);
std::cout << "The minimum value is: " << min;
return 0;
}
What does the following code snippet output?
#include <iostream>
int main() {
int x = 5;
switch (x) {
case 1:
std::cout << "One";
break;
case 2:
std::cout << "Two";
break;
case 3:
std::cout << "Three";
break;
default:
std::cout << "Other";
break;
}
return 0;
}
What does the following code snippet output?
#include <iostream>
int main() {
int x = 2;
switch (x) {
case 1:
std::cout << "One";
break;
case 2:
std::cout << "Two";
break;
case 3:
std::cout << "Three";
break;
default:
std::cout << "Other";
break;
}
return 0;
}
What does the following code snippet output?
#include <iostream>
int main() {
int x = 3;
switch (x) {
case 1:
std::cout << "One";
case 2:
std::cout << "Two";
case 3:
std::cout << "Three";
break;
default:
std::cout << "Other";
break;
}
return 0;
}