Assess Your C Skills

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.

#include < setjmp.h >
static jmp_buf buf;

main()
{
  volatile int b;
  b =3;

  if(setjmp(buf)!=0)
  {
    printf("%d ", b);
    exit(0);
  }
  b=5;
  longjmp(buf , 1);
}
The output for this program is:





Consider the following program:
main()
{
  char *p;
  char buf[10] ={ 1,2,3,4,5,6,9,8};
  p = (buf+1)[5];
  printf("%d" , p);
}
The output for this program is:





Consider the following program:
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);
}
The value of j at the end of the execution of the this program is:





How to supress a warning (can not convert int to bool) raised by this code snippet
int x = 1;
int y = 3;
bool z = x + y;






int (*func)(int x, char y) how do return this function pointer from a function named func2 which takes void args





a^=b^=a^=b what does this do?





How do you implement a function which takes variable number of arguments





static volatile const long int x =0; how does x behave?





What is the memory allocated by the following definition ? int (*x)[10];





What is the memory allocated by the following definition ? int *x[10];





What would be the output of the following code
int x = 1, y = 0;
if (x, y)
  printf("Hellon");
else
  printf("Hin");





What would be the output of following code
int x*=10;
printf("%d", x);





How memmove() is different from memcpy()





Find out the functionality of the below code snippet
FindFunctionalityOfthisCode(x,n)
{
  val = x;
  do 
  {
    if(n % 2)
      val *= x;
    else
      val *= val;
  }while(n /= 2);
}





calloc(2) works?





char *p= "Cpp-Programming.Net" ; *p='M' does it work?





What would be the output of the following code
if (!strcmp("cpp-programming.net", "cpp-programming.net\0"))
  printf("hellon");
else
  printf("hin");





What would be the output of the following program if print() is called
print()
{
  int x = 3;
  switch(x)
  {  
  case 1:
  {
    printf("1");
  }
  break;
  case 2:
  {
     printf("2");
    case 3:
      printf("3");
  }
  break;
  default:
    printf("def");
    break;
  }
}





int x = 1;
x++++;
output?





What would be the output of the following program?
int x[] = {1,2,3};
int i= 0;
X[i]=i++;
printf("x[i]=%dn", x[i]);







Share and Enjoy:
  • Print
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • Add to favorites
  • LinkedIn
  • Propeller
  • Reddit
  • StumbleUpon
  • Technorati
  • Twitter
  • Yahoo! Bookmarks

Related posts:

  1. i64toa – Converts a 64 bit integer to string
  2. Advanced Test in C: The 0×0A Best Questions for C Programmers
  3. Unsigned long to string (ultostr)
  4. Print In Reverse-Order
  5. char** from static variables

Tags:

4 Responses to “Assess Your C Skills”

  1. joe says:

    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.

  2. ponnada says:

    Joe,

    regarding first one

    if (!strcmp(”cpp-programming.net”, “cpp-programming.net\0”))
      printf(”hello\n”);
    else
      printf(”hi\n”);
    

    ====> 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??

  3. ponnada says:
    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.

  4. ponnada says:

    Regarding switch case program, I’d missed braces for switch, thanks for pointing out.

Leave a Reply