C Language
Test your knowledge of C programming fundamentals including operators, functions, structures, bit fields, and file handling.
Questions
Which of the following statements is not true?
- getchar() reads one character at a time till the user presses enter.
- putchar() prints one character on the screen at a time, read by the standard input.
- getch() reads alphanumeric character from the input device.
- getch() does not display the character input by it on the screen.
- All of the above
Which of the following statements is/are true for the “structures” in C language?
- We cannot create nesting of “structures” in a C program.
- By default, all the member structures are private.
- We can pass a structure element to a function.
- Both 1 and 3
- Both 2 and 3
Find out the output of the given program in binary language.
#include <stdio.h>
#include <conio.h>
int main() {
int a = 7, b = 15, c;
c = a | b;
printf("The result comes out to be : %d", c);
getch();
}
- The result comes out to be 0111.
- The result comes out to be 1111.
- The result comes out to be 0111.
- The result comes out to be 0110.
- Error in the program
Which of the following options is true for functions in C language?
- Functions operate on actual address argument and return the address back to the calling function.
- The values of formal arguments passed by the calling function are received by the actual arguments of the called function.
- The detail of inner working of a function is known to the whole program.
- A class can always access the functions of another class with friend function.
- None of these
Which of the following statements is/are true regarding the making of a program to store the data using “bit fields” in C language?
- Array of bit fields are not permitted.
- Pointer cannot be used for addressing the bit fields directly.
- We can use only unsigned integer data type with bit fields.
- A bit field is set up with a structure declaration.
- All of the above
Which of the following symbols is used for the comparison of two values?
- ==
- &&
- ++
- --
- +
Which of the following is not an object-oriented programming language?
- C
- C++
- C#
- Java
- F#
Which of the following is a unary operator?
- &&
- ||
- >=
- ++
- <=
Which of the following standard functions accepts two arguments while calling?
- Strspn();
- Strnset();
- Strnsetu();
- Strdup();
- Strncpyl();
Which of the following is a bitwise operator?
- !=
- &
- ==
- <
- >
With which boolean operator is logical AND denoted?
- &&
- ||
- >=
- <=
- !
Which of the following options is correct for file handling?
- Random access file takes less time for reading than a sequential file.
- getw() function reads all data types from a file.
- Closall() function closes all the opened files in a program.
- ofstream is a class to read the data from a file.
- None of these
Find out the output of the given program.
#include <stdio.h>
#include <conio.h>
main()
{
int s = 25, d;
d = s % 10;
if (d == 5) {
s = s / 10;
printf("\\nresult is=%d%d", s * s++, d * d);
}
else {
printf("\\n invalid number");
}
getch();
}
- Invalid number
- 425
- 625
- 525
- Compiler error