[go: up one dir, main page]

0% found this document useful (0 votes)
81 views8 pages

Capegimini - Pseudo - Code 4

Uploaded by

Kaushiki Mishra
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
81 views8 pages

Capegimini - Pseudo - Code 4

Uploaded by

Kaushiki Mishra
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

Capgemini Pseudocodes-IV

what is expected time complexity of given code ?

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

3.What will be the output of following code :

#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

4.What will be correct output for given piece of pseudo code


int x=100/2*50
print(x)

A.1
B.2500
C.250
D.100
Ans- B

5.What will be output for given pseudo code?


int a=9
print(+-~a)

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 :

integer a = 984, b=10


float c
c = a / b
print c
A. 984
B. 98.4
C. 98
D. Error

Ans. C

17.
What will be output of given pseudo code for input 7 :

1. read the value of n


2. set m=1,t=0
3. if m > n
4. go to line 9
5. else
6. t=t+m
7. m+=1
8. go to line 3
9. display T
10. stop
A. 32
B. 76
C. 56
D. 28

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.

integer a = 40, b = 35, c = 20, d = 10


Comment about the output of the following two statements:

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:

print ( a > 45 OR b > 50 AND c > 10 )


print ( ( a > 45 OR b > 50 ) AND c > 10 )
A. 0 and 1
B. 0 and 0
C. 1 and 1
D. 1 and 0

Ans. D

22.

What is the output of given code :

#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

You might also like