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

C Quiz

This document contains 30 multiple choice questions related to C programming. The questions cover various C programming concepts like data types, operators, input/output functions, control structures, arrays and strings. The correct answers to the questions are not provided. The document is divided into two parts - Part A contains 20 questions and Part B contains 10 questions.

Uploaded by

Lalith Kartikeya
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
141 views

C Quiz

This document contains 30 multiple choice questions related to C programming. The questions cover various C programming concepts like data types, operators, input/output functions, control structures, arrays and strings. The correct answers to the questions are not provided. The document is divided into two parts - Part A contains 20 questions and Part B contains 10 questions.

Uploaded by

Lalith Kartikeya
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 20

Sreenidhi Institute of Science and Technology

(An Autonomous Institute)


C Programming QUIZ-1
(I B.Tech Ist SemCSE- E2)

[Q001]. Determine which of the following VALID identifiers are. If invalid, state the
reason.
(a) sample1
(f) variable
name_and_age

(b) 5sample

(c) data_7

(g) 91-080-100

(d) return

(h) name & age

(e) #fine
(i) _val (j)

[Q002]. Determine which of the following VALID character constants are. If invalid,
state the reason.
(a) 'y'

(b) '\r' (c) 'Y'

(d) '@'

(f) 'word'

(g) '\0' (h) '\?' (i) '\065'

(e) '/r'
(j) '\'' (k) ' '

[Q003]. Determine which of the following VALID string constants are. If invalid,
state the reason.
(a) 'Hi Friends'
(d) "4325.76e-8"
"You\'re great"
(g) ""

(b) "abc, def,ghi"

(c) "Qualification

(e) "Don\'t sleep"

(f) "He said,

(h) "

"

(i) "Rs.100/-"

[Q004]. Determine which of the following numerical values are valid constants. If a
constant is
valid, specify whether it is integer or real. Also, specify the base for each valid
integer constant.
(a) 10,500

(b) 080

(c) 0.007

(f) 0.2e-0.3

(g) 0.2e 0.3

(h) 0xaf9s82 (i) 0XABCDEFL

(k) 87654321l (l) 87654321

(d) 5.6e7

(e) 5.6e-7
(j) 0369CF

[Q005]. Determine which of the following floating-point constants are VALID for
the quantity (5 * 100000).
(a) 500000

(b) 0.5e6

(c) 5E5

(f) 500E3

(g) .5E6

(h) 50e4

(k) All of the above

(d) 5e5
(i) 50.E+4

(e) 5e+5
(j) 5.0E+5

(l) None of these

[Q006]. What will be the output of the following program :


void main()
{
printf("%f",123.);
}
(a)123

(b)Compile-Time Error

(c)123.00

(d)123.000000

[Q007]. What will be the output of the following program :


void main()
{
printf("%d",sizeof(integer));
}
(a)2

(b)Compile-Time Error
(d)None of these

(c)4

[Q008]. What will be the output of the following program :


void main()
{
charstr[]="C For Swimmers";
printf("%d",sizeofstr);
}

(a)14

(b)Compile-Time Error
(d)None of these

(c)15

[Q009]. What will be the output of the following program :


void main()
{
charstr[]="C For Swimmers";
printf("%d",++(sizeof(str)));
}
(a)14

(b)Compile-Time Error
(d)None of these

(c)15

[Q010]. What will be the output of the following program :


void main()
{
charstr[]="C For Swimmers";
printf("%d",-sizeof(str));
}
(a)14

(b)Compile-Time Error

(c)-15

(d)-14

[Q011]. What will be the output of the following program :


void main()
{
printf("%d",!(100==100)+1);
}
(a)100

(b)0

(c)1

(d)2

[Q012]. What will be the output of the following program :


void main()
{
int x=5,y=6,z=2;
z/=y/z==3?y/z:x*y;
printf("%d",z);
}
(a)Compile-Time Error

(b)2

(c)0

(d)1

[Q013]. What will be the output of the following program :


void main()
{
printf("%d %d %d",5,!5,25-!25);
}
(a)5 10 22

(b)5 5 25

(c)5 0 25

(d)5 1 24

[Q014]. What will be the output of the following program :


int main()
{
int a=500,b=100,c=30,d=40,e=19;
a+=b-=c*=d/=e%=5;
printf("%d %d %d %d %d",a,b,c,d,e);
}
(a)500 100 30 40 4

(b)Run-Time Error (c)700 200 300 10 4(d)300 -200 300 10 4

[Q015]. What will be the output of the following program :

void main()
{
int a=500,b=100,c=30,d=40,e=19;
if ((((a > b) ? c : d) >= e) && !((e <= d) ? ((a / 5) == b) : (c == d)))
printf("Success");
else
printf("Failure");
}
(a)VALID : Success (b)VALID : Failure (c)INVALID

(d)None of these

[Q016]. What will be the output of the following program :


void main()
{
int a=1,b=2,c=3,d=4;
printf("%d",!a?b?!c:!d:a);
}
(a)1

(b)2

(c)3

[Q017]. What will be the output of the following program :


void main()
{
inti=12345,j=-13579,k=-24680;
long ix=123456789;
shortsx=-2222;
unsignedux=5555;
printf("\n%d %d %d %ld %d %u",i,j,k,ix,sx,ux);

(d)4

printf("\n\n%3d %3d %3d\n%3ld %3d %3u",i,j,k,ix,sx,ux);


printf("\n\n%8d %8d %8d\n%15ld %8d %8u",i,j,k,ix,sx,ux);
printf("\n\n%-8d %-8d\n%-8d %-15ld\n%-8d %-8u",i,j,k,ix,sx,ux);
printf("\n\n%+8d %+8d\n%+8d %+15ld\n%+8d %8u",i,j,k,ix,sx,ux);
printf("\n\n%08d %08d\n%08d %015ld\n%08d %08u",i,j,k,ix,sx,ux);
}
[Q018]. What will be the output of the following program :
void main()
{
inti=12345,j=0xabcd9,k=077777;
printf("%d %x %o",i,j,k);
printf("\n%3d %3x %3o",i,j,k);
printf("\n%8d %8x %8o"i,j,k);
printf("\n%-8d %-8x %-8o",i,j,k);
printf("\n%+8d %+8x %+8o",i,j,k);
printf("\n%08d %#8x %#8o",i,j,k);
}

[Q019]. What will be the output of the following program :


void main()
{
char c1='A', c2='B', c3='C';
printf("%c %c %c",c1,c2,c3);
printf("\n%c%c%c",c1,c2,c3);
printf("\n%3c %3c %3c",c1,c2,c3);
printf("\n%3c%3c%3c",c1,c2,c3);
printf("\nc1=%c c2=%c c3=%c",c1,c2,c3);

}
[Q020]. What will be the output of the following program :
void main()
{
float a=2.5, b=0.0005, c=3000.;
printf("%f %f %f",a,b,c);
printf("\n%3f %3f %3f",a,b,c);
printf("\n%8f %8f %8f",a,b,c);
printf("\n%8.4f %8.4f %8.4f",a,b,c);
printf("\n%8.3f %8.3f %8.3f",a,b,c);
printf("\n%e %e %e",a,b,c);
printf("\n%3e %3e %3e",a,b,c);
printf("\n%12e %12e %12e",a,b,c);
printf("\n%8.2e %8.2e %8.2e",a,b,c);
printf("\n%-8f %-8f %-8f",a,b,c);
printf("\n%+8f %+8f %+8f",a,b,c);
printf("\n%08f %08f %08f",a,b,c);
printf("\n%#8f %#8f %#8f",a,b,c);
printf("\n%g %g %g",a,b,c);
printf("\n%#g %#g %#g"a,b,c);
}

void main()
{
charstr[]="C For Swimmers";
printf("%s",str);
printf("\n%.5s",str);

printf("\n%8.*s",5,str);
printf("\n%-10s %.1s",str+6,str);
}

[Q022]. What will be the output of the following program :


void main()
{
int a=1,b=2,c=3;
scanf("%d %*d %d",&a,&b,&c);
printf("a=%d b=%d c=%d",a,b,c);
}
[NOTE : 3 values entered by the user are:100 200 300]
(a)1 2 3
300 3

(b)100 200 300

(c)100 200 3

[Q023]. What will be the output of the following program :


void main()
{
char line[80]; // Max. length=80 Chars
scanf("%[^,]s",line);
printf("\n%s",line);
}
[NOTE : THE USER INPUT IS:Dear Friends, What is the output?]
(a)Compile-Time Error
(b)Dear Friends
output?
(d)None of these

[Q024]. What will be the output of the following program :

(c)What is the

(d)100

void main()
{
chara,b,c;
scanf("%c%c%c",&a,&b,&c);
printf("a=%c b=%c c=%c",a,b,c);
}
[NOTE : THE USER INPUT IS :A B C]
(a)a=A b=B c=C
(d)None of these

(b)a=A b= c=B

(c)a=A b= c=C

[Q025]. What will be the output of the following program :


void main()
{
inti=1;
float f=2.25;
scanf("%d a %f",&i,&f);
printf("%d %.2f",i,f);
}
[NOTE : THE USER INPUT IS:5 5.75]
(a)1 2.25
these

(b)5 5.75

(c)5 2.25

[Q026]. What will be the output of the following program :


void main()
{
chara,b,c;
scanf("%c %c %c",&a,&b,&c);
printf("a=%c b=%c c=%c",a,b,c);

(d)None of

}
[NOTE : THE USER INPUT IS :ABC DEF GHI]
(a)a=ABC b=DEF c=GHI
(d)None of these

(b)a=A b=B c=C

(c)a=A b=D c=G

[Q027]. What will be the output of the following program :


void main()
{
char a[80],b[80],c[80];
scanf("%1s %5s %3s",a,b,c);
printf("%s %s %s",a,b,c);
}
[NOTE : THE USER INPUT IS:CMeansSea Ocean Vast]
(a)C O V
(b)C Means Sea
(d)None of these

(c)C Ocean Vas

[Q028]. What will be the output of the following program :


void main()
{
inta,b,c;
scanf("%1d %2d %3d",&a,&b,&c);
printf("Sum=%d",a+b+c);
}
[NOTE : THE USER INPUT IS :123456 44 544]
(a)Sum=480
these

(b)Sum=594

(c)Sum=589

[Q029]. What happens when the following program is executed :


void main()
{

(d)None of

char line[80];
scanf("%[^1234567890\n]",line);
}
(a)Accepts the string that contains DIGITS only.
(b)Accepts the string that contains DIGITS and NEWLINE characters.
(c)Accepts the string that contains anything other than the DIGITS and NEWLINE
characters.
(d)None of these

[Q030]. What happens when the following program is executed :


void main()
{
char line[80];
scanf("%[^*]",line);
}
(a)Accepts the string that contains DIGITS & ALPHABETS only.
(b)Accepts the string that contains * or asterisk characters only.
(c)Accepts the string that contains anything other than the * or asterisk character.
(d)None of these
PART-B
[Q001]. What will be the output of the following program :
void main()
{
printf();
}
(a)Run-Time Error (b)Compile-Time Error
(d)None of these

(c)No Output

[Q002]. What will be the output of the following program :


void main()
{
printf(NULL);
}
(a)Run-Time Error (b)Compile-Time Error
(d)None of these

(c)No Output

[Q003]. What will be the output of the following program :


void main()
{
printf("%%",7);
}
(a)7

(b)Compile-Time Error

(c)%

(d)%%
[Q004]. What will be the output of the following program :
void main()
{
printf("//",5);
}
(a)5

(b)Compile-Time Error

(c)/

[Q005]. What will be the output of the following program :


void main()
{
printf("d%",8);
}

(d)//

(a)8

(b)Compile-Time Error
(d)None of these

(c)d%

[Q006]. What will be the output of the following program :


void main()
{
printf("%d"+0,123);
}
(a)123

(b)Compile-Time Error
(d)None of these

(c)No Output

[Q007]. What will be the output of the following program :


void main()
{
printf("%d"+1,123);
}
(a)123
Output

(b)Compile-Time Error

(c)d

[Q008]. What will be the output of the following program :


void main()
{
printf("%d",printf("Hi!")+printf("Bye"));
}
(a)ByeHi!6
(b)Hi!Bye6
(d)None of these

(c)Compile-Time Error

[Q009]. What will be the output of the following program :


void main()

(d)No

{
printf("%d",printf("Hi!")*printf("Bye"));
}
(a)ByeHi!6
these

(b)Hi!Bye9

(c)Hi!Bye

[Q010]. What will be the output of the following program :


void main()
{
printf("%d",printf("")+printf(""));
}
(a)0

(b)No Output
(d)None of these

(c)Compile-Time Error

[Q011]. What will be the output of the following program :


void main()
{
printf("Hi Friends"+3);
}
(a)Hi Friends
(b)Friends
(d)None of these

(c)Hi Friends3

[Q012]. What will be the output of the following program :


void main()
{
printf("C For ") + printf("Swimmers");
}
(a)Compile-Time Error
(d)None of these

(b)C For Swimmers (c)Run-Time Error

[Q013]. What will be the output of the following program :

(d)None of

void main()
{
printf("\/\*\-*\/");
}
(a)Run-Time Error (b)\/*-*\/

(c)/*-*/

(d)None of these

[Q014]. What will be the output of the following program :


int main()
{
int main=7;
{
printf("%d",main);
return main;
}
printf("Bye");
}
(a)Compile-Time Error
(d)7

(b)Run-Time Error (c)7Bye

[Q015]. What will be the output of the following program :


void main()
{
main();
}
(a)Compile-Time Error
(d)None of these

(b)Run-Time Error (c)Infinite Loop

[Q016]. What will be the output of the following program :


void main()
{

printf("Work" "Hard");
}
(a)Work
(d)WorkHard

(b)Hard

(c)No Output

[Q017]. What will be the output of the following program :


void main()
{
charstr[]="%d";
intval=25;
printf(str,val);
}
(a)Compile-Time Error
(d)None of these

(b)Run-Time Error (c)25

[Q018]. What will be the output of the following program :


void main()
{
intval=75;
printf("%d",val,.,.);
}
(a)Compile-Time Error
(d)None of these

(b)Unpredictable

(c)75

[Q019]. What will be the output of the following program :


void main()
{
intval=10;
printf("%d",val+1,"%d",val--);
}

(a)10

(b)11 10

(c)11 9

(d)10 9

[Q020]. What will be the output of the following program :


void main()
{
intval=5;
printf("%d %d %d %d",val,--val,++val,val--);
}
(a)3 4 6 5
these

(b)5 5 6 5

(c)4 4 5 5

(d)None of

[Q021]. What will be the output of the following program :


void main()
{
intval=5,num;
printf("%d",scanf("%d %d",&val,&num));
}
[NOTE : ASSUME 2 values are entered by the user are stored in the variables 'val'
& 'num' respectively.]
(a)1
these

(b)2

(c)5

[Q022]. What will be the output of the following program :


#define Compute(x,y,z) (x+y-z)
void main()
{
int x=2,y=3,z=4;
printf("%d",Compute(y,z,(-x+y)) * Compute(z,x,(-y+z)));
}
(a)40

(b)30
(d)None of these

(c)Compile-Time Error

[Q023]. What will be the output of the following program :

(d)None of

void main()
{
int m=10,n=20;
printf("%d %d %d",m/* m-value */,/* n-value */n,m*/* Compute m*n */n);
}
(a)Run-Time Error (b)10 20 200
(d)None of these

(c)Compile-Time Error

[Q024]. What will be the output of the following program :


void main()
{
int m=10,n=20;
/* printf("%d",m*n);
}
(a)VALID but No Output
(d)None of these

(b)VALID : Prints 200

(c)Compile-Time Error

[Q025]. What will be the output of the following program :


void main()
{
intval=97;
"Printing..."+printf("%c",val);
}
(a)Printing...97

(b)97

(c)Compile-Time Error

[Q026]. What will be the output of the following program :


void main()
{
intval=5;
val=printf("C") + printf("Skills");

(d)a

printf("%d",val);
}
(a)Skills5
(d)CSkills7

(b)C1

(c)Compile-Time Error

[Q027]. What will be the output of the following program :


void main()
{
charstr[]="Test";
if ((printf("%s",str)) == 4)
printf("Success");
else
printf("Failure");
}
(a)TestFailure
(d)Test

(b)TestSuccess

(c)Compile-Time Error

[Q028]. What will be the output of the following program :


void main()
{
intval=5;
printf("%*d",val);
}
(a) 5
these

(b)5

(c)Compile-Time Error

[Q029]. What will be the output of the following program :


void main()
{

(d)None of

intval=5;
printf("%d5",val);
}
(a)Compile-Time Error

(b)5

(c)55

(d)

[Q030]. What will be the output of the following program :


void main()
}
intval=5;
printf("%d",5+val++);
{
(a)Compile-Time Error

(b)5

(c)10

(d)11

You might also like