C Programming Fundamentals

Test your knowledge of C programming concepts including variables, data types, operators, pointers, control structures, and code output prediction.

14 Questions Published

Questions

Question 1 Multiple Choice (Single Answer)

There are some rules for declaring a variable in C language. Which of the following rules is/are not correct for declaring variables?

  1. The variable name cannot start with a digit.
  2. The variables cannot be a C keyword.
  3. They must begin with a character without spaces but underscore is not permitted.
  4. Both 1 and 3.
  5. None of these
Question 2 Multiple Choice (Single Answer)

Which of the following conversion symbols used in printf statements in C language is/are invalid?

  1. %p
  2. %g
  3. %o
  4. None of these
  5. All of the above
Question 3 Multiple Choice (Single Answer)

How many keywords are there in ANSI C?

  1. 32
  2. 33
  3. 34
  4. 35
  5. 36
Question 4 Multiple Choice (Single Answer)

Which of the following statements is/are true?

  1. Long integer occupies 4 bytes in the memory and its range is - 2147483648 to + 2147483647.
  2. Unsigned integer occupies 2 bytes in the memory and its range is 0 to 65535.
  3. Double occupies 8 bytes in the memory and its range is 1.7e - 308 to 1.7e + 308.
  4. Only 1 and 3.
  5. All of the above.
Question 5 Multiple Choice (Single Answer)

#include<stdio.h><stdio.h><stdio.h></stdio.h></stdio.h>
<stdio.h>#include<conio.h><conio.h></conio.h></stdio.h>
<stdio.h>int main()</stdio.h>
<stdio.h>{</stdio.h>
<stdio.h>int a=9,b=10,c;</stdio.h>
<stdio.h><conio.h>c=(b<a || b>a);</conio.h></stdio.h>
<stdio.h>printf(c=%d,c);</stdio.h>
<stdio.h>getch();
</stdio.h>}

Find the output of the above program or error, if any.

  1. c=1
  2. c=0
  3. c=-1
  4. garbage value
  5. error in the program
Question 6 Multiple Choice (Single Answer)

If x = 9.3, y = x - 5.1, z = x - 0.2, k = y + 1.5, a = k + 2.2, b = a - 1.6, h = z + 2.8, u = 625 / 25 and t = 7, then solve the following expression according to the precedence.
P = (x - y + z / k - a / b - h + u % t).

  1. P = - 2.54768
  2. P = - 2.45748
  3. P = - 2.54678
  4. P = - 2.54878
  5. P = - 2.45768
Question 7 Multiple Choice (Single Answer)

#include<stdio.h><stdio.h><stdio.h><stdio.h></stdio.h></stdio.h></stdio.h>
<stdio.h>#include<coni.h><conio.h><conio.h><conio.h></conio.h></conio.h></conio.h></stdio.h>
<stdio.h>int main(</stdio.h><stdio.h>)</stdio.h>
<stdio.h>{</stdio.h>
<stdio.h>unsigned long v=-1;</stdio.h>
<stdio.h>printf(v=%lu,v);</stdio.h>
<stdio.h>getch();
</stdio.h>}

Find the output of the above program or error, if any.

  1. v=-1
  2. v=4294967295
  3. v=4294967296
  4. v=0
  5. error in the program
Question 8 Multiple Choice (Single Answer)

C language has some special characters. Which of the following special characters is invalid?

  1. : (colon)
  2. ; (semicolon)
  3. # (hash)
  4. , (comma)
  5. none of these
Question 9 Multiple Choice (Single Answer)

What will be the value of c after the execution of the following program?
#include<stdio.h>
<stdio.h>#include<conio.h><conio.h></conio.h></stdio.h>
<stdio.h>int main()</stdio.h>
<stdio.h>{</stdio.h>
<stdio.h>int c=1,d=0;</stdio.h>
<stdio.h>while(d<=9)</stdio.h>
<stdio.h>{</stdio.h>
<stdio.h>printf(
%d%d,++d,++c);</stdio.h>
<stdio.h>}</stdio.h>
<stdio.h>getch();</stdio.h>
<stdio.h>}</stdio.h>

  1. 9
  2. 10
  3. 11
  4. 12
  5. None of these
Question 10 Multiple Choice (Single Answer)

Which of the following statements is correct for the given program?
#include<stdio.h><stdio.h></stdio.h>
<stdio.h>#include<conio.h></stdio.h>
<stdio.h>int main()</stdio.h>
<stdio.h>{</stdio.h>
<stdio.h>int a1,a2,c=3,pt;</stdio.h>
<stdio.h>pt=&c;</stdio.h>
<stdio.h>a1=3
(c+5);</stdio.h>
<stdio.h>a2=3*(*pt+5);</stdio.h>
<stdio.h>printf(a1=%d,a2=%d,a1,a2);</stdio.h>
<stdio.h>getch();</stdio.h>
<stdio.h>}</stdio.h>

  1. a=24, b=24
  2. a=12, b=24
  3. We cannot perform addition in pointers(*pt+5)
  4. None of these
  5. Error in the program
Question 11 Multiple Choice (Single Answer)

What will be the output of the given program?
#include<stdio.h><stdio.h><stdio.h></stdio.h></stdio.h>
<stdio.h>#include<conio.h><conio.h></conio.h></stdio.h>
<stdio.h>int main()</stdio.h>
<stdio.h>{</stdio.h>
<stdio.h>char x='G';</stdio.h>
<stdio.h>switch(x)</stdio.h>
<stdio.h>{</stdio.h>
<stdio.h>if(x=='B')</stdio.h>
<stdio.h>{</stdio.h>
<stdio.h>case 'd':</stdio.h>
<stdio.h>printf(%c,'o');</stdio.h>
<stdio.h>case 'B':</stdio.h>
<stdio.h>printf(%s,Bad);</stdio.h>
<stdio.h>}</stdio.h>
<stdio.h>else</stdio.h>
<stdio.h>{</stdio.h>
<stdio.h>case 'G':</stdio.h>
<stdio.h>printf(%s,Good);</stdio.h>
<stdio.h>default:</stdio.h>
<stdio.h>printf(%s,Boy);</stdio.h>
<stdio.h>}</stdio.h>
<stdio.h>}</stdio.h>
<stdio.h>getch();</stdio.h>
<stdio.h>}</stdio.h>

  1. GoodBoy
  2. Good
  3. Boy
  4. None of these
  5. Error in the program
Question 12 Multiple Choice (Single Answer)

The C programs are converted into machine language using a/an ____________.

  1. assembler
  2. compiler
  3. interpreter
  4. operating system
  5. both 2 and 3
Question 13 Multiple Choice (Single Answer)

Find out the values of variables a and b after the execution of program or find out the error if any.
#include<stdio.h><stdio.h><stdio.h><stdio.h><stdio.h></stdio.h></stdio.h></stdio.h></stdio.h>
<stdio.h>#include<conio.h><conio.h><conio.h><conio.h></conio.h></conio.h></conio.h></stdio.h>
<stdio.h>int main()</stdio.h>
<stdio.h>{</stdio.h>
<stdio.h>int a,*b=&a,**c=&b;</stdio.h>
<stdio.h>a=5;</stdio.h>
<stdio.h>**c=15;</stdio.h>
<stdio.h>*b=**c;</stdio.h>
<stdio.h>printf(a=%d,b=%d,a,*b);</stdio.h>
<stdio.h>getch();</stdio.h>
<stdio.h>}</stdio.h>

  1. a=5, b=15
  2. a=15, b=15
  3. a=5, b=5
  4. a=15, b=5
  5. Error in the program
Question 14 Multiple Choice (Single Answer)

Find out the output of the given program or find the error if any.
#include<stdio.h><stdio.h></stdio.h>
<stdio.h>#include<conio.h><conio.h></conio.h></stdio.h>
<stdio.h>int main()</stdio.h>
<stdio.h>{</stdio.h>
<stdio.h>int s=25,d;</stdio.h>
<stdio.h>d=s%10;</stdio.h>
<stdio.h>if(d==5)</stdio.h>
<stdio.h>{</stdio.h>
<stdio.h>s=s/10;</stdio.h>
<stdio.h>printf(
result is=%d%d,ss++,dd);</stdio.h>
<stdio.h>}</stdio.h>
<stdio.h>else</stdio.h>
<stdio.h>{</stdio.h>
<stdio.h>printf(
invalid number);</stdio.h>
<stdio.h>}</stdio.h>
<stdio.h>getch();</stdio.h>
<stdio.h>}</stdio.h>

  1. Invalid number
  2. Result is 425
  3. Result is 625
  4. Result is 525
  5. Error in the program