Quick Revision

GK One-Line Question & Answer

15541+ short questions with short answers, covering every category and sub-category on the site — no long articles to scroll through. Good for a fast recap before an exam, or a few minutes of daily practice.

OOP Using C++ → Operators in C++ 28

What is the output: int x=5; if(x=0) cout<<'T'; else cout<<'F';
F
click to copy
What is the output: int x=5; int y=++x>5?1:0; cout<<y<<x;
16
click to copy
What is the output: cout<<(int)(2.9)<<(int)(2.1)<<(int)(-2.9);
22-2
click to copy
What is the output: int x=1; cout<<(x<<1)<<(x<<2)<<(x<<3);
248
click to copy
What is the output: int x=5,y=3; cout<<(x>y)-(x<y);
1
click to copy
What is the output: int x=5; cout<<(x&-1);
5
click to copy
What is the output: int x=5; cout<<(x|-1);
-1
click to copy
What is the output: int x=5; cout<<(x^-1);
-6
click to copy
What is the output: int x=0; cout<<(x||x++);
1
click to copy
What is the output: int x=5; cout<<((x%2)+2)%2;
1
click to copy
What is the output: int x=100; cout<<(x/10/10);
1
click to copy
What is the output: int x=5; int y=x++; cout<<x-y;
1
click to copy
What is the output: int x=5; int y=++x; cout<<x-y;
0
click to copy
What is the output: int a=2,b=3; cout<<(a<<b)-(b<<a);
4
click to copy
What is the output: int x=7; cout<<(x&0x55);
5
click to copy
What is the output: int x=0; cout<<(++x,++x,++x);
3
click to copy
What is the output: int x=5; cout<<(x>0?(x>10?'H':'M'):'L');
M
click to copy
What is the output: int a=1,b=0; cout<<(a|b)<<(a&b)<<(a^b);
101
click to copy
What is the output: int x=255; cout<<(x&0xAA)<<' '<<(x&0x55);
170 85
click to copy
What is the output: int x=5; cout<<((x&4)?1:0)<<((x&2)?1:0)<<((x&1)?1:0);
101
click to copy
What is the output: int x=5; cout<<(x>0&&cout<<'Y');
1Y
click to copy
What is the output: int x=5; x^=3; x^=3; cout<<x;
5
click to copy
What is the output: int x=2; cout<<(x<<x);
8
click to copy
What is the output: int x=5; auto y=(x,x+1,x+2); cout<<y;
7
click to copy
What is the output: int x=1; for(int i=0;i<4;i++) cout<<(x<<=1);
2481
click to copy
What is the output: int x=5,y=5; cout<<(x==y?'E':'N');
E
click to copy
What is the output: int x=5; cout<<(x?x-1:x+1);
4
click to copy
What is the output: int x=4; cout<<(x&3)<<(x|3)<<(x^3);
077
click to copy

OOP Using C++ → Control Statements 12

What is the output: int x=5; (x>3)?cout<<'Y':cout<<'N';
Y
click to copy
What is the output: for(int i=0;i<3;i++) cout<<i*i;
014
click to copy
What is the output: int x=5; switch(x){case 5: cout<<x++; case 6: cout<<x;}
56
click to copy
'What is the output: int i=5; do{cout<<i (1, 6, 74, 4, 4, 'What is the output: for(int i=0;i<10;i+=3) cout<<i;', 'i+=3 from 0 to 10?', '0369', '0369', '036', '036', 'Compile error', 'Compile error', 'Undefined', 'Undefined', NULL, 'option_a', '0
6
click to copy
What is the output: for(int i=0;i<10;i+=3) cout<<i;
0369
click to copy
What is the output: int x=0; while(x<5) x+=2; cout<<x;
6
click to copy
What is the output: for(int i=0;i<5;i++) if(i%3==0) cout<<i;
03
click to copy
What is the output: int x=10; for(;x>0;x/=2) cout<<x%2;
0101
click to copy
What is the output: int n=12; int f=1; for(int i=2;i<=n;i++) f*=i; cout<<f;
479001600
click to copy
What is the output: for(int i=0;i<3;i++) for(int j=0;j<3;j++) if(i==j) cout<<i+j;
024
click to copy
What is the output: int x=1; while(x<1000) x*=3; cout<<x;
2187
click to copy
What is 'switch expression' in C++23?
Not yet in C++23; only statement form exists
click to copy