Upload
haritha-yandrapragada
View
133
Download
0
Embed Size (px)
Citation preview
Dept. of Industrial Relations and Placements, Communication and soft skills
Subject Name:- C Language
1) The Real constants in C can be expressed in which of the following formsa)Fractional form only b)Exponential form only c)ASCII form only d) a & b
2) The program, which translates high-level program into its equivalent machine language program, is calleda)Transformer b)Language processor c)Converter d) none of the above
3) Consider the following statements.
i)Multiplication associates left to right ii)Division associates left to rightiii)Unary Minus associates right to left iv)subtraction associates left to righta)only i and ii are true b)all are false c)all are true d)only iii and iv are true
4) What will be the value of variable a in the following code?unsigned char a;a = 0xFF + 1;printf("%d", a);a)0xFF b)0x100 c)0 d)0*0
5) What is the output of the following program?#include <stdio.h>void main(){printf("\n10!=9 : %5d",10!=9);}
a) 10b) Errorc) None of the above
6) What is the output of the following program? #include<stdio.h>void main(){int x=10;(x<0)?(int a =100):(int a =1000);printf(" %d",a);}
a)Error b)1000 c)100 d)None of these options
7) Which of the following shows the correct hierarchy of arithmetic operations in C(a), **, * or /, + or - (b), **, *, /, +, - (c), **, /, *, +, - (d), / or *, - or +
8) What is the output of the following code?#include<stdio.h>
void main(){int a=14;a += 7;a -= 5;a *= 7;printf("\n%d",a);}
a)112 b)98 c)89 d)None of these options
9) What is the output of the following code? #include<stdio.h>#define T tvoid main(){char T = `T`;printf("\n%c\t%c\n",T,t);}
a)Error b)T t c)T T d)t t 10) The statement which prints out the values 1 to 10 on separate lines, is
a)for( count = 1; count <= 10; count = count + 1) printf("%d\n",count);b)for( count = 1; count < 10; count = count + 1) printf("%d\n",count); c)for( count = 0; count <= 9; count = count + 1) printf("%d ",count);d)for( count = 1; count <> 10; count = count + 1) printf("%d\n",count);
11) What does the term `call-by-reference` refer to?a)Passing a copy of a variable into a function. b)Passing a pointer to a variable into a function.
c)Choosing a random value for a variable. d)A function that does not return any values. 12) What is the output of the following code?
#include<stdio.h>void swap(int&, int&);void main(){int a = 10,b=20;swap (a++,b++);printf("\n%d\t%d\t",a, b);}void swap(int& x, int& y){x+=2;y+=3;}
a)14, 24 b)11, 21 c)10, 20 d)Error
13) What is the output of the following program code #include<stdio.h>void abc(int a[]){a++;a[1]=612;}main(){char a[5];abc(a);printf("%d",a[4]);}
a)100 b)612 c)Error d)None of these options
14) which of the following is true about recursive functioni). it is also called circular definitionii). it occurs when a function calls another function more than onceiii). it occurs when a statement within the function calls the function itself iv). a recursive function cannot have a return statement within it"a) i and iii b) i and ii c) ii and iv d)i, iii and iv
15) What will happen if you assign a value to an element of an array whose subscript exceeds the size of the array?a)The element will be set to 0 b)Nothing, its done all the timec)Other data may be overwritten d)Error message from the compiler
16) What is the output of the following code? #include<stdio.h>void main(){int arr[2][3][2]={{{2,4},{7,8},{3,4},}, {{2,2},{2,3},{3,4}, }}; printf("\n%d",**(*arr+1)+2+7);}a)16 b)7 c)11 d) Error
17) If int s[5] is a one dimensional array of integers, which of the following refers to the third element in the array?a)*( s + 2 ) b)*( s + 3 ) c)s + 3 d)s + 2
18) What is the output of the following code? void main(){int i = 100, j = 200;const int *p=&i;p = &j;printf("%d",*p);}a)100 b)200 c)300 d)None of the above
19) What is the output of the following code? #include<stdio.h>void main(){int arr[] = {10,20,30,40,50};int *ptr = arr;printf("\n %d\t%d\t",*ptr++,*ptr);}a)10 20 b)10 10 c)20 20 d)20 10
20) Which of these are reasons for using pointers?1.To manipulate parts of an array2.To refer to keywords such as for and if3.To return more than one value from a function 4.To refer to particular programs more convenientlya)1 & 3 b)Only 1 c)Only 3 d)All of the above
21) During initializing a uniona)Only one member can be initialised. b)All the members will be initialised.
C)Initialisation of a union is not possible. d)None of these options22) What would be the output of the following program?
#include <stdio.h>main(){printf("\n%c", "abcdefgh"[4]);}a)abcdefgh b)d c)e <------ans d)error
23) What is the output of the following code ?void main(){int a=0;int b=0;++a == 0 || ++b == 11;printf("\n%d,%d",a,b);}a)0, 1 b)1, 1 c)0, 0 d)1, 0
24) What is the output of the following program? #include<stdio.h>void main(){while (1){if (printf("%d",printf("%d")))break;elsecontinue;}
}The output isa)Compile time errorb)Goes into an infinite loopc)Garbage values d)None of these options
25) Which of the following is the correct way of declaring a float pointer:a)float ptr; b)float *ptr; c)*float ptr; d)None of the above
26) What is the output of the code
main(){char s[ ]="man";int i;for(i=0;s[ i ];i++)printf("\n%c%c%c%c",s[ i ],*(s+i),*(i+s),i[s]);}
27) What is the output of the code
main(){float me = 1.1;double you = 1.1;if(me==you)printf("I love U");elseprintf("I hate U");}
28) What is the output of the code
main(){sstatic int var = 5;printf("%d ",var--);if(var)main();}
29) What is the output of the code
main(){int c[ ]={2.8,3.4,4,6.7,5};int j,*p=c,*q=c;for(j=0;j<5;j++) printf(" %d ",*c);++q; }for(j=0;j<5;j++){
printf(" %d ",*p);++p; }}
30) What is the output of the code
main(){int i=-1,j=-1,k=0,l=2,m;m=i++&&j++&&k++||l++;printf("%d %d %d %d %d",i,j,k,l,m);}
31) What is the output of the code
main(){char *p;printf("%d %d ",sizeof(*p),sizeof(p));}
32) What is the output of the code
main(){int i=3;switch(i){default:printf("zero");case 1: printf("one");break;case 2:printf("two");break;case 3: printf("three");break;}}
33) What is the output of the codemain(){printf("%x",-1<<4);}
34) What is the output of the code main() { char string[]="Hello World"; display(string); } void display(char *string)
{ printf("%s",string); }
35) What is the output of the codemain(){int c=- -2;printf("c=%d",c);}
36) What is the output of the code#define int charmain(){int i=65;printf("sizeof(i)=%d",sizeof(i));}
37) What is the output of the codemain(){int i=10;i=!i>14;Printf ("i=%d",i);}
38) What is the output of the code #include<stdio.h>main(){int a[2][2][2] = { {10,2,3,4}, {5,6,7,8} };int *p,*q;p=&a[2][2][2];*q=***a;printf("%d----%d",*p,*q);}
39) What is the output of the codemain(){struct xx{int x=3;char name[]="hello";};struct xx *s;printf("%d",s->x);printf("%s",s->name);}
40) What is the output of the code#include<stdio.h>
main(){struct xx{int x;struct yy{char s;struct xx *p;};struct yy *q;};}
41) What is the output of the codemain(){int i=5;printf("%d%d%d%d%d%d",i++,i--,++i,--i,i);}
42) What is the output of the codemain(){char *p="hai friends",*p1;p1=p;while(*p!='\0') ++*p++;printf("%s %s",p,p1);}
43) What is the output of the code#define clrscr() 100main(){clrscr();printf("%d\n",clrscr());}
44) What is the output of the codevoid main(){char far *farther,*farthest;printf("%d..%d",sizeof(farther),sizeof(farthest));}
45) What is the output of the codemain(){
int i=400,j=300;printf("%d..%d");}
46) What is the output of the code
main(){char *p;p="Hello";printf("%c\n",*&*p);}
47) ) What is the output of the codemain(){int i=1;while (i<=5){printf("%d",i);if (i>2)goto here;i++;}}fun(){here:printf("PP");}
48) What is the output of the code main()
{static char names[5][20]={"pascal","ada","cobol","fortran","perl"};int i;char *t;t=names[3];names[3]=names[4];names[4]=t;for (i=0;i<=4;i++)printf("%s",names[i]);}
49) What is the output of the codevoid main(){int i=5;printf("%d",i++ + ++i);}
50) What is the output of the codevoid main(){int i=5;printf("%d",i+++++i);}
51) What is the output of the code
main(){int i;clrscr();printf("%d", &i)+1;scanf("%d", i)-1;}
a. Runtime error.b. Runtime error. Access violation.c. Compile error. Illegal syntaxd. None of the above
52) What is the output of the code
main(int argc, char *argv[]){(main && argc) ? main(argc-1, NULL) : return 0;}
a. Runtime error.b. Compile error. Illegal syntaxc. Gets into Infinite loopd. None of the above
53) What is the output of the code
main(){int i = 0xff ;printf("\n%d", i<<2);}
a. 4b. 512c. 1020d. 1024
54) What is the output of the code
#define SQR(x) x * x
main(){printf("%d", 225/SQR(15));}
a. 1b. 225c. 15d. none of the above
55) What is the output of the code
union u{struct st{int i : 4;int j : 4;int k : 4;int l;}st;int i;}u;
main(){u.i = 100;printf("%d, %d, %d",u.i, u.st.i, u.st.l);}
a. 4, 4, 0b. 0, 0, 0c. 100, 4, 0d. 40, 4, 0
56) What is the output of the code
union u{union u
{int i;int j;}a[10];int b[10];}u;
main(){printf("\n%d", sizeof(u));printf(" %d", sizeof(u.a));// printf("%d", sizeof(u.a[4].i));}
a. 4, 4, 4b. 40, 4, 4c. 1, 100, 1d. 40 400 4
57) What is the output of the code
main(){int i, j, *p;i = 25;j = 100;p = &i; // Address of i is assigned to pointer pprintf("%f", i/(*p) ); // i is divided by pointer p}
a. Runtime error.b. 1.00000c. Compile errord. 0.00000
58) What is the output of the code
main(){int i, j;scanf("%d %d"+scanf("%d %d", &i, &j));printf("%d %d", i, j);}
a. Runtime error.b. 0, 0c. Compile errord. the first two values entered by the user
59) What is the output of the code
main(){char *p = "hello world";p[0] = 'H';printf("%s", p);}
a. Runtime error.b. “Hello world”c. Compile errord. “hello world”
60) What is the output of the code
main(){char * strA;char * strB = I am OK;memcpy( strA, strB, 6);}
a. Runtime error.b. I am OKc. Compile errord. I am O
61) How will you print % character?a. printf(“\%”)b. printf(“\\%”)c. printf(“%%”)d. printf(“\%%”)
62) What is the output of the code
const int perplexed = 2;#define perplexed 3
main(){#ifdef perplexed#undef perplexed#define perplexed 4#endifprintf("%d",perplexed);}
a. 0b. 2c. 4d. none of the above
63) What is the output of the code
struct Foo{char *pName;};
main(){struct Foo *obj = malloc(sizeof(struct Foo));clrscr();strcpy(obj->pName,"Your Name");printf("%s", obj->pName);}
a. Your Nameb. compile errorc. Named. Runtime error
64) What is the output of the code
struct Foo{char *pName;char *pAddress;};
main(){
struct Foo *obj = malloc(sizeof(struct Foo));clrscr();obj->pName = malloc(100);obj->pAddress = malloc(100);
strcpy(obj->pName,"Your Name");strcpy(obj->pAddress, "Your Address");
free(obj);printf("%s", obj->pName);printf("%s", obj->pAddress);}
a. Your Name, Your Addressb. Your Address, Your Addressc. Your Name Your Named. None of the above
65) What is the output of the code
main(){char *a = "Hello ";char *b = "World";clrscr();printf("%s", strcat(a,b));}
a. Hellob. Hello Worldc. HelloWorldd. None of the above
66) What is the output of the code
main(){char *a = "Hello ";char *b = "World";clrscr();printf("%s", strcpy(a,b));}
a. “Hello”b. “Hello World”
c. “HelloWorld”d. None of the above
67) What is the output of the code
void func1(int (*a)[10]){printf("Ok it works");}
void func2(int a[][10]){printf("Will this work?");}
main() { int a[10][10];func1(a); func2(a);}
a. Ok it worksb. Will this work?c. Ok it worksWill this work?d. None of the above
68) What is the output of the code
main(){printf("%d, %d", sizeof('c'), sizeof(100));}
a. 2, 2b. 2, 100c. 4, 100d. 4, 4
69) What is the output of the code
main(){int i = 100;clrscr();printf("%d", sizeof(sizeof(i)));}
a. 2b. 100c. 4d. none of the above
70) What is the output of the code
main(){int c = 5;printf("%d", main||c);}
a. 1b. 5c. 0d. none of the above
71) What is the output of the code
main(){char c;int i = 456;clrscr();c = i;printf("%d", c);}
a. 456b. -456c. random numberd. none of the above
72) What is the output of the code
void main (){int x = 10;printf ("x = %d, y = %d", x,--x++);}
a. 10, 10b. 10, 9c. 10, 11d. none of the above
73) What is the output of the code
main(){int i =10, j = 20;clrscr();printf("%d, %d, ", j-- , --i);printf("%d, %d ", j++ , ++i);}
a. 20, 10, 20, 10b. 20, 9, 20, 10c. 20, 9, 19, 10d. 19, 9, 20, 10
74) What is the output of the code
main(){int x=5;clrscr();
for(;x==0;x--) {printf("x=%d\n”", x--);}}
a. 4, 3, 2, 1, 0b. 1, 2, 3, 4, 5c. 0, 1, 2, 3, 4d. none of the above
75) What is the output of the code
main(){int x=5;
for(;x!=0;x--) {printf("x=%d\n", x--);}}
a. 5, 4, 3, 2,1b. 4, 3, 2, 1, 0c. 5, 3, 1d. none of the above
76) What is the output of the code
main(){{unsigned int bit=256;printf("%d", bit);}{unsigned int bit=512;printf("%d", bit);}}
a. 256, 256b. 512, 512c. 256, 512d. Compile error
77) What is the output of the code
main(){int i;clrscr();for(i=0;i<5;i++){printf("%d\n", 1L << i);}}a. 5, 4, 3, 2, 1b. 0, 1, 2, 3, 4c. 0, 1, 2, 4, 8d. 1, 2, 4, 8, 16
78) What is the output of the code
main(){signed int bit=512, i=5;
for(;i;i--){printf("%d\n", bit = (bit >> (i - (i -1))));}}
a. 512, 256, 128, 64, 32b. 256, 128, 64, 32, 16c. 128, 64, 32, 16, 8d. 64, 32, 16, 8, 4
79) What is the output of the code
main(){signed int bit=512, i=5;
for(;i;i--){printf("%d\n", bit >> (i - (i -1)));}}
a. 512, 256, 0, 0, 0b. 256, 256, 0, 0, 0c. 512, 512, 512, 512, 512d. 256, 256, 256, 256, 256
80) What is the output of the code
main(){if (!(1&&0)){printf("OK I am done.");}else{printf("OK I am gone.");}}
a. OK I am doneb. OK I am gonec. compile errord. none of the above
81) What is the output of the code
main(){if ((1||0) && (0||1)){
printf("OK I am done.");}else{printf("OK I am gone.");}}
a. OK I am doneb. OK I am gonec. compile errord. none of the above
82) What is the output of the code
main(){signed int bit=512, mBit;
{mBit = ~bit;bit = bit & ~bit ;
printf("%d %d", bit, mBit);}}
a. 0, 0b. 0, 513c. 512, 0d. 0, -513