Questions 1: What will be the output of the following code?
#include < stdio.h >
int main()
{
const int x=5;
const int *const p=&x;
x++;
printf("\n %d",x);
return 0;
}
Answer: d) Compile Error
Questions 2: Predict the output of the following code :
#include < stdio.h >
int main()
{
int n=35;
int i=0;
while (n%10!=0){
n=n+3;
i++;
}
n=n+i;
printf("%d",n);
return 0;
}
Answer: c) 55
Questions 3: What will be the output of the following code?
#include < stdio.h >
int main(){
int n=10;
int i=5;
int sum=0;
while (i < n){
sum=sum+i;
i++;
}
printf("%d",sum);
return 0;
}
Answer: a) 35
Questions 4: Predict the output of the following code :
#include < stdio.h >
int main(){
int a;
float b=7.0;
switch (a=b+1)
{
case 8: printf("TCS Digital");
break;
default: printf("TCS Ninja");
}
return 0;
}
Answer: a) TCS Digital
Questions 5: Predict the output of the following code :
#include < stdio.h >
int main(){
int number=6;
int k=2,i=2;
int sum=0;
while (i<=number){
k = k * i;
i = i +1 ;
}
printf("%d",k);
return 0;
}
Answer: b) 1440
Questions 6: How many times 'a' will be displayed on the screen?
#include < stdio.h >
int main(){
int input=25;
while (input > 0){
if(input > 0 && input < =10)
printf("a");
else if(input >10 && input < =20)
printf("aa");
else if(input >20 && input <= 30)
printf("aaa");
input--;
}
return 0;
}
Answer: b) 45
Questions 7: What will be the output of the following code ?
#include < stdio.h >
int main(){
int n=5,i=2;
while(i<=n){
printf("%d",i);
i++;
}
return 0;
}
Answer: b) 2 3 4 5
Questions 8: What will be the output of the following question?
#include < stdio.h >
int main(){
int j=2,k=5,m=6,n=9;
while(j < k){
while(m < n)
{
printf("Hello");
m++;
}
j++;
}
return 0;
}
Answer: b) Hello Hello Hello
Questions 9: What will be the output of the following question?
#include < stdio.h >
int main(){
int number=4;
while(number!=8)
{
printf("\n%d",2*number);
number=number+2;
}
return 0;
}
Answer: b) 8 12
Questions 10: What will be the output of the following code?
#includeint main() { int data=5,counter; for(counter=1;counter<=5;counter++) data+=counter; printf("%d",data); return 0; }
Answer: d) 20