Test - 4 Answers
- What is the output of the following program?
#include<stdio.h>
main(){
int i = 1;
while(++i <= 5)
printf("%d ",i++);
}
ANS: 2 4
- What is the output of the below code snippet?
#include<stdio.h>
main(){
int a = 5, b = 3, c = 4;
printf("a = %d, b = %d", a, b, c);
}
ANS: a=5, b=3
- What is the output of the following code snippet?
#include<stdio.h>
main(){
short unsigned int i = 0;
printf("%u", --i);
}
ANS: 65535
- What is the output of the following program?
#include<stdio.h>
main(){
char *p = NULL;
printf("%c", *p);
}
ANS: Runtime Error
- What is the outpout of the following program?
#include<stdio.h>
main(){
enum { india, is=7, GREAT };
printf("%d %d", india, GREAT);
}
ANS: 0 8
- What is the output of the following program?
#include<stdio.h>
void f(int a[]){
int i;
for(i=0; i<3; i++)
a[i]++;
}
main(){
int i,a[] = {10, 20, 30};
f(a);
for(i=0; i<3; ++i)
printf("%d ",a[i]);
}
ANS: 11 21 31
- What is the output of the below code snippet?
#include<stdio.h>
main(){
char s[]="hello", t[]="hello";
if(s==t) printf("eqaul strings");
}
ANS: No output
- What will be the output of the program?
#include<stdio.h>
int main(){
int y=128;
const int x=y;
printf("%d", ++x);
}
ANS: Error
- What will be the output of the program?
#include<stdio.h>
int main(){
printf("%d",125/20&&30%5);
}
ANS: 0
- What will be the output of the program?
#include<stdio.h>
int i=0;
int main(){
printf("%d",5+7&&i<<10?12:i*10);
}
ANS: 0