Monday, 3 December 2012

Interview apps on C (part 2)


1. What is the output of the following program?

#include<stdio.h>
#define SQR(x) (x*x)
int main(){
    int a,b=3;
    a= SQR(b+2);
    printf("%d",a);
    return 0;
}
a) 25
b) 11
c) error
d) garbage value


2. In which line of the following, an error would be reported?

#include<stdio.h>
1. #define CIRCUM(R) (3.14*R*R);
2. int main()
3. {
4.       float r=1.0,c;
5.       c= CIRCUM(r);
6.       printf("\n%f",c);
7.       if(CIRCUM(r))==6.28)
8.           printf("\nGobbledygook");
9.       return 0;
10. }

a) line 1
b) line 5
c) line 6
d)line 7



3. What is the type of the variable b in the following declaration?

#define FLOATPTR float*
FLOATPTR a,b;

a) float
b) float pointer
c) int
d) int pointer



4. In the following code:

#include"stdio.h";
int main(){
    FILE *fp;
    fp= fopen("trial","r");
}

fp points to:
a) The first character in the file.
b) A structure which contains a "char" pointer which points to the first character in the file.
c) The name of the file.
d) None of the above.

No comments:

Click Here To add Comment

Post a Comment

Blogger Widgets