Showing posts with label find out the ouput ?. Show all posts
Showing posts with label find out the ouput ?. Show all posts

Saturday, March 17, 2012

What is the output ?

6. Give sizeof(a) in bytes for the following: (assume 32bit PC)

char *a[10];
char (*a)[10];
char (**a)[20];
char (*a)(int x, char c);

Ans: 40 , 4 , 4 , 4

7. Find out the output :

#include<stdio.h>
main()
{
    int n1 = 10, n2 = 12;
    if( n2=!0)
        printf("Result is:%d\n",(n1/n2));
    else
        printf("cannot divide by zero\n");
}
Ans: Result is:10

8. Find out the output:

#include<stdio.h>
main()
{
    long int one_million;
    one_million=1,000,000;
    printf("One million is %d",one_million);
}
Ans: One million is 1

9.  what is the output ?

#include<stdio.h>
#define f(a,b) a##b
#define g(a) #a
#define h(a) g(a)
main()
{
    printf("%s %s\n",h(f(1,2)),g(f(1,2)));
}
Ans: 12 f(1,2)

10. what is the output?

#include<stdio.h>
main()
{
    static int j=printf("%d",456);;
    printf("%d",j);
}
Ans: Error

11. What is the output ?

#include<stdio.h>
main()
{
int i = 5;
int j;
j=sizeof(i++);
printf("%d",i);
}
Ans: 5

12. What is the output of z?

#include<stdio.h>
main()
{
int z,x=5,y=-10,a=4,b=2;
z=x++ - --y * b / a;
}
Ans: 10