Capgemini placement papers with solution
141 / 483
What will be the output of the program?
#include
#include
int main()
{
int *p;
p = (int *)malloc(20); /* Assume p has address of 1314 */
free(p);
printf("%u", p);
return 0;
}
A1314
BGarbage value
C1316
DRandom address
Answer: Option D
Explanation:Here is no explanation for this answer
ShortCut By :: DevanandAnswer is 16953360
RANDOM VALUES
Submit Your Solution
142 / 483
#include<stdio.h> int main()
{
show();
return 0;
}
void show()
{
printf("I'm the greatest");
}
ACompier error: Type mismatch in redeclaration of show.
BI', the greatest
CLinker error
DNone of these
Answer: Option B
Explanation:When the compiler sees the function show it doesn't know anything about it. So the default return type (ie, int) is assumed. But when the compiler sees the actual definition of show mismatch occurs since it is declared as void. Hence there will be a warning, if you have set treat warning as error then option A will be, else option B will be. Here Option B will be correct.
Submit Your Solution
143 / 483
#include<stdio.h> void main()
{
printf("%p",main);
}
ACompilation error
BGarbage Value
CSome address will be printed.
DNone of these
Answer: Option C
Explanation:Function names are just addresses (just like array names are addresses). main() is also a function. So the address of function main will be printed. %p in printf specifies that the argument is an address. They are printed as hexadecimal numbers
Submit Your Solution
144 / 483
#include<stdio.h>
#define max(a,b) (a>b)? a:b
int main()
{
int a,b; a=3; b=4;
printf("%d",max(a,b));
return 0;
}
A3
B4
C12
D0
ECompilation Error
Answer: Option B
Explanation:Here is no explanation for this answer
Submit Your Solution
145 / 483
#include<stdio.h>
void main()
{
int i=5;
printf("%d",i+++++i);
}
A5
B6
CCompiler Error
D7
Answer: Option C
Explanation:The expression i+++++i is parsed as i ++ ++ + i which is an illegal combination of operators.
Submit Your Solution
146 / 483
Note: 32 bit compiler
#include<stdio.h>
int main(){
float **(*ptr)[4]=(float **(*)[4])0;
ptr+=5;
printf("%d %d",ptr,sizeof ptr);
return 0;
}
A0 2
B160 8
C40 2
D80 4
ECompilation error
Answer: Option D
Explanation:Here is no explanation for this answer
Submit Your Solution
147 / 483
In Breadth First Search of Graph, which of the following data structure is used?
AStack.
BQueue.
CLinked List.
DNone of these.
Answer: Option B
Explanation:Here is no explanation for this answer
Submit Your Solution
148 / 483
An algorithm is made up of two independent time complexities f (n) and g (n). Then the complexities of the algorithm is in the order of
Af(n) x g(n)
BMax ( f(n),g(n))
CMin (f(n),g(n))
Df(n) + g(n)
Answer: Option B
Explanation:Here is no explanation for this answer
Submit Your Solution
149 / 483
Let S be the original stack and S1 and S2 the two additional stacks then the following pseudo code is to reverse the stack S:
while (S not empty)
{
push(S1,pop(S));
}
while(S1 not empty)
{
push(S2,pop(S1));
}
while(S2 not empty)
{
push(S,pop(S2));
} ?
ATRUE
BFalse
CNot Answer
Answer: Option A
Explanation:Here is no explanation for this answer
Submit Your Solution
150 / 483
void fn( ){
char c;
cin.get(c);
if (c != '\n') {
fn( );
cout.put(c);
}
}
AThe string entered is printed as it is
BThe string entered is printed in reverse order.
CIt will go in an infinite loop.
DIt will print an empty line.
Answer: Option B
Explanation:Here is no explanation for this answer
Submit Your Solution
Here is the list of questions asked in placement papers of Capgemini 2020 placement papers of Capgemini 2020. Practice Capgemini Written Test Papers with Solutions and take Q4Interview Capgemini Online Test Questions to crack Capgemini written round test. Overall the level of the Capgemini Online Assessment Test is moderate. Only those candidates who clear the written exam will qualify for the next round, so practic all the questions here and take all the free tests before going for final selection process of Capgemini