Capegimini - Pseudo - Code 4
Capegimini - Pseudo - Code 4
1.
int count = 0 ;
for (int i = N; i > 0; i /= 2)
for (int j = 0; j < i; j++)
count++;
A. O(N)
B. O(N^2)
C. O(Nlog(N))
D. O(log(N))
Ans- A
2.
int num=1234543;
for(int i=1;i<=num;i++)
ans=ans xor i;
print(ans);
A. 0
B. 1
C. 1234544
D. 1234543
Ans- A
#include<stdio.h>
int main(){
int i = 16;
i =! i > 15;
printf(“i = %d”,i);
return 0;
}
A. i = -1
B. i = 0
C. i = 1
D. Error : Undefined operation
Ans. B
A.1
B.2500
C.250
D.100
Ans- B
A.-1
B.9
C.-9
D.10
Ans. D
6.
What will be the output of following code :
#include<stdio.h>
int main()
{
int x = 2;
(x & 1) ? printf(“true”) : printf(“false”);
return 0;
}
A. true
B. false
C. 0
D. Error
Ans-B
7.
What will be the output of following code :
#include<stdio.h>
int main()
{
int a = NULL – true;
printf(“%d”,a);
return 0;
}
A. -1
B. Garbage value
C. 0
D. Error
Ans. A
8.
What will be the output of following code :
#include<stdio.h>
int main()
{
if(printf(“0”))
printf(“inside if block”);
else
printf(“inside else block”);
return 0;
}
A. inside else block
B. 0
C. 0inside if block
D. Error – If can not have print statement
Ans. C
9.
What will be the output of following code :
#include<stdio.h>
int main(){
int i = 5, j = 4;
if(!printf(“”))
printf(“%d %d”, i, j);
else
printf(“%d %d”, i++, ++j);
return 0;
}
A. 5 5
B. 5 4
C. 5 6
D. 6 6
Ans. B
10.
What will be the output of following code :
#include<stdio.h>
int main()
{
if(sizeof(‘\0’))
printf(“inside if block”);
else
printf(“inside else block”);
return 0;
}
A. inside if block
B. inside else block
C. Null Pointer Exception
D. None of these
Ans. A
11.
What will be the output of following code :
#include<stdio.h>
int main()
{
int i = 65;
switch(i)
{
case 65:
printf(“Integer 65”);
break;
case ‘A’:
printf(“Char 65”);
break;
default:
printf(“Bye”);
}
return 0;
}
A. Integer 65
B. Char 65
C. Bye
D. Error : Duplicate Values
Ans. D
12.
#include<stdio.h>
int main()
{
switch(2/3)
{
case 1:
printf(“case 1 executed “);
case 2:
printf(“case 2 executed “);
break;
default:
printf(“Default block executed”);
}
return 0;
}
A. case 1 executed
B. case 2 executed
C. Default block executed
D. Error : Switch statements can not hold
Ans. C
13.
What will be the output of following code :
#include<stdio.h>
int main()
{
int i = 1;
switch(i)
{
case i:
printf(“case 1 executed”);
break;
case i + 1;
printf(“case 2 executed”);
break;
default:
printf(“default block executed”);
break;
}
return 0;
}
A. case 1 executed
B. case 2 executed
C. default block executed
D. Error : i is not usable
Ans. D
14.
#include<stdio.h>
int main(){
while(printf(“%d”, 5) < 4)
printf(“Loop “);
return 0;
}
A. Loop Loop Loop Loop Loop
B. Infinite loop
C. 5Loop 5Loop 5Loop 5Loop 5Loop
D. None of these
Ans. B
15.
What is the output of given code :
#include<stdio.h>
int main()
{
long double a;
long double b;
int arr[sizeof(!a+b)];
printf(“%d”,sizeof(arr));
}
A. Run time Error
B. 32
C. 64
D. No output
Ans. C
16.
What will be the output of the following code :
Ans. C
17.
What will be output of given pseudo code for input 7 :
Ans. D
18.
What will be output of given pseudo code for input 2 :
int fun(int n)
{
if(n == 4)
return n;
else
return 2*fun(n+1);
}
A. 4
B. 8
C. 16
D. Error
Ans. C
19.
What will be output of given pseudo code :
#include<stdio.h>
using namespace std;
int main()
{
int a =0,b=1,c=2;
*( ( a+1==1) ? &b : &a)= a? b : c;
printf(“%d, %d, %d \n”, a , b, c );
return 0;
}
A. 0 1 2
B. 0 2 0
C. 0 2 2
D. Error
Ans. C
20.
print a * b / c – d
print a * b / (c – d)
A. Differ by 80
B. Same
C. Differ by 50
D. Differ by 160
Ans. A
21.
integer a = 60, b = 35, c = -30
What will be the output of the following two statements:
Ans. D
22.
#include<stdio.h>
int main()
{
int x =4, y = 0;
int z;
z = (y++, y);
printf(“%d\n”, z);
return 0;
}
A. 1
B. 0
C. Undefined Behavior due to order of evaluation can be different.
D. Compilation Error
Ans. A
24.
What will be the output of following code :
int A[5][5], k, j;
for(k = 0; k<5; ++k)
for(j=0; j<5; j++)
A[k][j] = A[j][k];
A. It transposes the given matrix A
B. It does not alter the given matrix.
C. It makes the given matrix A, symmetric
D. None of the above.
Ans. A
25.
If n equals to 188 Count of numbers x smaller than or equal to n such
that n+x = n^x
A.10
B.32
C.8
D.92
Ans. C