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++ 21

What is the output: int x=5; cout<<(x*x+x+1)%7;
3
click to copy
What is the output: int x=0; cout<<(x (1, 6, 73, 3, 4, 'What is the output: int x=16; while(x&(x-1)) x&=x-1; cout<<x;', 'Clear bits until power of 2: x=16?', '16', '16', '8', '8', '1', '1', 'Compile error', 'Compile error', NULL, 'option_a', '16=10000; 16&15=0: already power of 2. Loop doesn't run. Output: 16.
2026-05-25
click to copy
What is the output: int x=16; while(x&(x-1)) x&=x-1; cout<<x;
16
click to copy
What is the output: int x=5; cout<<(x+(x>>31));
5
click to copy
What is the output: int x=5; cout<<((x>>31)^x)-((x>>31));
5
click to copy
What is the output: int x=5,y=3; cout<<(x^y^y);
5
click to copy
What is the output: int x=5; cout<<(x!=0?1:0)<<(x>0?1:-1);
11
click to copy
What is the output: int a=4,b=7; cout<<(a|b)-(a&b);
3
click to copy
What is the output: int x=5; cout<<(x+0)<<(x*1)<<(x-0)<<(x/1);
5555
click to copy
What is the output: unsigned x=5; cout<<(-x);
4294967291
click to copy
What is the output: int x=5; cout<<+(+x)<<-(-x);
55
click to copy
What is the output: int x=5; cout<<(x>0&x<10);
1
click to copy
What is the output: int x=5; cout<<(x>0|x>10);
1
click to copy
What is the output: int x=5; auto op=[](int a,int b,int c){return a?b:c;}; cout<<op(x>3,x*2,x/2);
10
click to copy
What is the output: int x=5; cout<<max({x,x*2,x-1,x+3});
10
click to copy
What is the output: int x=5; cout<<min({x,x*2,x-1,x+3});
4
click to copy
What is the output: int x=5; cout<<(x%10)<<(x/10);
50
click to copy
What is the output: int x=5; cout<<clamp(x*3,0,10);
10
click to copy
What is the output: int x=5; cout<<(x&0)==0;
1
click to copy
What is the output: int x=5; cout<<(x|0x80000000u);
-2147483643
click to copy
What is the output: int x=5; cout<<(bool)(x&(x+1));
1
click to copy

OOP Using C++ → Control Statements 19

What is the output: for(int i=0;i<5;i++) {if(i%2==0)continue; if(i>3)break; cout<<i;}
13
click to copy
What is the output: int x=5; switch(x){case 5: cout<<x; x=0; case 0: cout<<x; break;}
50
click to copy
What is the output: for(int i=0;i<3;i++) {for(int j=0;j<3;j++) {cout<<i*j<<' '; if(i==j&&i==1) goto done;}} done:;
0 0 0 1
click to copy
What is the output: for(int i=0;i<5;i++) cout<<(i&1?i*i:0);
01094
click to copy
What is the output: int a=1,b=2; if(a>0&&(b=5)>0) cout<<b;
5
click to copy
What is the output: for(int i=2;i<10;i++) if(i%2==0&&i%3==0&&i%5==0) cout<<i;
Nothing
click to copy
'What is the output: int x=5; if(x>0){x (1, 6, 74, 4, 4, 'What is the output: int n=0; for(int i=1;i*i<=25;i++) n++; cout<<n;', 'i where i^2<=25?', '5', '5', '6', '6', 'Compile error', 'Compile error', 'Undefined', 'Undefined', NULL, 'option_a', 'i=1
3
click to copy
What is the output: int n=0; for(int i=1;i*i<=25;i++) n++; cout<<n;
5
click to copy
What is the output: for(int i=0;i<3;i++) {int j=0; while(j<3) {cout<<i+j; j+=2;}}
0 2 1 3 2 4
click to copy
What is the output: int x=1; switch(x){default: cout<<'D'; case 1: cout<<'A'; break; case 2: cout<<'B';}
A
click to copy
What is the output: for(int i=1;i<10;i++) if(i%2==0) if(i%3==0) cout<<i;
6
click to copy
What is the output: int x=0; for(int i=0;i<5;i++) x=x>i?x:i; cout<<x;
4
click to copy
What is the output: int x=5; while(x>0) {cout<<x; x>>=1;}
531
click to copy
What is the output: for(int i=0,s=0;i<5;s+=i,i++) cout<<s;
01 3610
click to copy
What is the output: int x=2; do{x*=x;}while(x<1000); cout<<x;
256
click to copy
What is the output: for(int i=0;i<5;i++) {if(i==2) {i+=2; continue;} cout<<i;}
014
click to copy
What is the output: for(int i=0;i<3;i++) for(int j=0;j<3;j++) if(i==1&&j==1) {cout<<i*j; goto exit;} exit:;
1
click to copy
What is the output: int x=0; for(int i=1;i<=5;i++) for(int j=1;j<=5;j++) if(i==j) x++; cout<<x;
5
click to copy
What is the output: for(int i=1;i<=5;i++) cout<<(i%3==1?'A':i%3==2?'B':'C');
ABCAB
click to copy