C Programming Fundamentals
Test your knowledge of C programming concepts including variables, data types, operators, pointers, control structures, and code output prediction.
Questions
There are some rules for declaring a variable in C language. Which of the following rules is/are not correct for declaring variables?
- The variable name cannot start with a digit.
- The variables cannot be a C keyword.
- They must begin with a character without spaces but underscore is not permitted.
- Both 1 and 3.
- None of these
Which of the following conversion symbols used in printf statements in C language is/are invalid?
- %p
- %g
- %o
- None of these
- All of the above
How many keywords are there in ANSI C?
- 32
- 33
- 34
- 35
- 36
Which of the following statements is/are true?
- Long integer occupies 4 bytes in the memory and its range is - 2147483648 to + 2147483647.
- Unsigned integer occupies 2 bytes in the memory and its range is 0 to 65535.
- Double occupies 8 bytes in the memory and its range is 1.7e - 308 to 1.7e + 308.
- Only 1 and 3.
- All of the above.
#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.
- c=1
- c=0
- c=-1
- garbage value
- error in the program
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).
- P = - 2.54768
- P = - 2.45748
- P = - 2.54678
- P = - 2.54878
- P = - 2.45768
#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.
- v=-1
- v=4294967295
- v=4294967296
- v=0
- error in the program
C language has some special characters. Which of the following special characters is invalid?
- : (colon)
- ; (semicolon)
- # (hash)
- , (comma)
- none of these
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>
- 9
- 10
- 11
- 12
- None of these
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>
- a=24, b=24
- a=12, b=24
- We cannot perform addition in pointers(*pt+5)
- None of these
- Error in the program
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>
- GoodBoy
- Good
- Boy
- None of these
- Error in the program
The C programs are converted into machine language using a/an ____________.
- assembler
- compiler
- interpreter
- operating system
- both 2 and 3
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>
- a=5, b=15
- a=15, b=15
- a=5, b=5
- a=15, b=5
- Error in the program
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>
- Invalid number
- Result is 425
- Result is 625
- Result is 525
- Error in the program