This Quiz contains 20 questions, if you feel you are having strong C skills then it is a must quiz to assert your skills, please leave your feedback.
Related posts:
- i64toa – Converts a 64 bit integer to string
- Advanced Test in C: The 0×0A Best Questions for C Programmers
- Unsigned long to string (ultostr)
- Print In Reverse-Order
- char** from static variables
Tags: c quiz
if (!strcmp(”cpp-programming.net”, “cpp-programming.net�”))
printf(”hellon”);
else
printf(”hin”);
====> answer should print “hi” not “hello”
int counter (int i)
{
static int count =0;
count = count +i;
return (count );
}
main()
{
int i , j;
for (i=0; i <=5; i++)
j = counter(i);
}
answer is 15, not 12.
print()
{
int x = 3;
switch(x)
case 1:
{
printf("1");
}
break;
case 2:
{
printf("2");
case 3:
printf("3");
}
break;
default:
printf("def");
break;
}
answer is not 3 but compile error.
Joe,
regarding first one
====> answer should print “hi” not “hello”
Here, “cpp-programming.net”, “cpp-programming.net\0″ both strings are equal, strcmp returns zero if strings are equal, so here strcmp gets zero, and not zero is true, so “hello\n” printed, why do you think “Hi\n” should be printed??
int counter (int i) { static int count =0; count = count +i; return (count ); } main() { int i , j; for (i=0; i < =5; i++) j = counter(i); }>>answer is 15, not 12.
Yes, this is correct. I'd corrected it.
Regarding switch case program, I’d missed braces for switch, thanks for pointing out.