0% found this document useful (0 votes)
43 views

Self Test3

This JSON contains a summary of a 10 question self-test on computer programming concepts. The test covers topics like data types, operators, file handling, strings, pointers and more. Each question provides a code snippet and multiple choice answers to predict the output of the code.

Uploaded by

yisakabera123
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
43 views

Self Test3

This JSON contains a summary of a 10 question self-test on computer programming concepts. The test covers topics like data types, operators, file handling, strings, pointers and more. Each question provides a code snippet and multiple choice answers to predict the output of the code.

Uploaded by

yisakabera123
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Computer programming Self-Test 3

1. Output of the following code


# include <stdio.h>
# define scanf "%s Geeks For Geeks "
main()
{
printf(scanf, scanf);
getchar();
return 0;
}
a) %s Geeks For Geeks Geeks For Geeks
b) %s Geeks For Geeks %s Geeks For Geeks
c) %s Geeks For Geeks
d) none

2. Output of the following code


#include <stdio.h>
void main(){
unsigned char c=290;
printf("%d",c);
}
a) 34
b) 290
c) Garbage
d) ERROR
3. What will be the output of following program ?
#include <stdio.h>
void main(){
int a=0;
a=5||2|1;
printf("%d",a);
}
a) 1
b) 7
c) 0
d) 8
4. What will be the output of following program ?
#include <stdio.h>
enum numbers
{
zero, one, two, three , four=3,five,six,seven=0,eight
};
void main()
{
printf("%d,%d,%d,%d,%d,%d,%d,%d,
%d",zero,one,two,three,four,five,six,seven,eight);
}
a) 0,1,2,3,3,4,5,0,1
b) 0,1,2,4,5,6,7,8,9
c) 0,1,2,3,3,1,2,3,4
d) 0,1,2,3,3,4,5,0,9
5. What will be the output of following program ?

#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

You might also like