C Problems and Solutions - 2

6. What is the output?

#include<stdio.h>
main(){
char a[]="hellow";
char *b="hellow";
char c[5]="hellow";
printf("%s %s %s ",a,b,c);
printf(" ",sizeof(a),sizeof(b),sizeof(c));
}

Ans: hellow,hellow,hellow
6,2,5

7. What is the output?

#include<stdio.h>
main()
{
float value=10.00;
printf("%g %0.2g %0.4g %f",value,value,value,value)
}

Ans : 10,10,10,10.000000

8. main()
{
funct(int n);
{
switch(n)
case1:
m=2;
break;
case2:
m=5;
break;
case3:
m=7;
break;
default:
m=0;
}

Ans : output is m=0

9. #include<stdio.h>
void function1;
int i-value=100;
main()
{
i-value=50;
function1;
printf("i-value in the function=",i-value);
printf("i-value after the function=",i-value);
}
printf("i-value at the end of main=",i-value);
functioni()
i-value=25;

Ans: i-value in the function=25;
i-value after the function=50;
i-value at the end of the main=100;

10. what is output of the following program
main()
{
int i=3;
while(i--)
{
int i=100
i--;
printf("%d..",i);
}
}

Ans: 99..99..99..99