C Quiz
C Quiz
[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
(e) #fine
(i) _val (j)
[Q002]. Determine which of the following VALID character constants are. If invalid,
state the reason.
(a) 'y'
(d) '@'
(f) 'word'
(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) ""
(c) "Qualification
(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
(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
(d) 5e5
(i) 50.E+4
(e) 5e+5
(j) 5.0E+5
(b)Compile-Time Error
(c)123.00
(d)123.000000
(b)Compile-Time Error
(d)None of these
(c)4
(a)14
(b)Compile-Time Error
(d)None of these
(c)15
(b)Compile-Time Error
(d)None of these
(c)15
(b)Compile-Time Error
(c)-15
(d)-14
(b)0
(c)1
(d)2
(b)2
(c)0
(d)1
(b)5 5 25
(c)5 0 25
(d)5 1 24
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
(b)2
(c)3
(d)4
}
[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);
}
(c)100 200 3
(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
(b)5 5.75
(c)5 2.25
(d)None of
}
[NOTE : THE USER INPUT IS :ABC DEF GHI]
(a)a=ABC b=DEF c=GHI
(d)None of these
(b)Sum=594
(c)Sum=589
(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
(c)No Output
(c)No Output
(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)/
(d)//
(a)8
(b)Compile-Time Error
(d)None of these
(c)d%
(b)Compile-Time Error
(d)None of these
(c)No Output
(b)Compile-Time Error
(c)d
(c)Compile-Time Error
(d)No
{
printf("%d",printf("Hi!")*printf("Bye"));
}
(a)ByeHi!6
these
(b)Hi!Bye9
(c)Hi!Bye
(b)No Output
(d)None of these
(c)Compile-Time Error
(c)Hi Friends3
(d)None of
void main()
{
printf("\/\*\-*\/");
}
(a)Run-Time Error (b)\/*-*\/
(c)/*-*/
(d)None of these
printf("Work" "Hard");
}
(a)Work
(d)WorkHard
(b)Hard
(c)No Output
(b)Unpredictable
(c)75
(a)10
(b)11 10
(c)11 9
(d)10 9
(b)5 5 6 5
(c)4 4 5 5
(d)None of
(b)2
(c)5
(b)30
(d)None of these
(c)Compile-Time Error
(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
(c)Compile-Time Error
(b)97
(c)Compile-Time Error
(d)a
printf("%d",val);
}
(a)Skills5
(d)CSkills7
(b)C1
(c)Compile-Time Error
(b)TestSuccess
(c)Compile-Time Error
(b)5
(c)Compile-Time Error
(d)None of
intval=5;
printf("%d5",val);
}
(a)Compile-Time Error
(b)5
(c)55
(d)
(b)5
(c)10
(d)11