Self Test3
Self Test3
#include <stdio.h>
int main(){
int a,b,c;
a=0x10; b=011;
c=a+b;
printf("\nAddition is= %d",c);
return 0;
}
a) Addition is = 20
b) Addition is = 25
c) Addition is = Garbage
d) ERROR
6. What will be the output of following program ?
#include<stdio.h>
#include<string.h>
int main()
{
char str[10]="Hello";
printf("%d,%d\n",strlen(str),sizeof(str));
return 0;
}
a) 5,8
b) 5,10
c) 1,10
d) 1,5
7. What will be the output of following program ?
#include <stdio.h>
int main()
{
extern int ok;
printf("value of ok = %d",ok);
return 0;
}
extern int ok=1000;
a) Declaration error
b) value of ok = 1000.
c) Linking error
d) value of ok = 0.
8. Which files will get closed through the fclose() in the following program?
#include<stdio.h>
int main()
{
FILE *fs, *ft, *fp;
fp = fopen("A.C", "r");
fs = fopen("B.C", "r");
ft = fopen("C.C", "r");
fclose(fp, fs, ft);
return 0;
}
a) "A.C" "B.C" "C.C"
b) "B.C" "C.C"
c) "A.C"
d) Error in fclose()
9. What will be the output of following program ?
#include <stdio.h>
int main()
{
char *str="A%%B";
printf("A%%B ");
printf("%s\n",str);
return 0;
}
a) A%%B A%%B
b) A%B A%%B
c) A%%B
d) A%%B A%B
10. What will be the output of following program ?
#include<stdio.h>
int main()
{
printf("%d,%d,%d\n",sizeof(char*),sizeof(int*),sizeof(float*));
return 0;
}
a) 1,4,4
b) 2,4,8
c) 8,8,8
d) none