1.
1) Which among the below is not a data type associated with C ?
Correct Answer
C. Object
Explanation
The correct answer is "object" because in the C programming language, there is no built-in data type called "object". C primarily supports data types like int, float, and void, but not object. Object-oriented programming concepts and the associated object data type are typically found in languages like C++, Java, and C#.
2.
2) All keywords in C are _____________.
Correct Answer
A. Lowercase letters
Explanation
In the C programming language, all keywords are written in lowercase letters. Keywords are predefined words that have special meanings and are reserved for specific purposes in the language. By using lowercase letters for keywords, it helps to distinguish them from user-defined identifiers or variables. Using uppercase or camelcase letters for keywords would result in syntax errors or unexpected behavior in the program. Therefore, the correct answer is lowercase letters.
3.
3) Which among the following is odd one out?
Correct Answer
B. Scanf()
Explanation
The odd one out is scanf() because it is used for input, while the other options (printf(), putchar(), and fprintf()) are used for output.
4.
4) What is the size of int data type ?
Correct Answer
C. Depends on the system/ compiler
Explanation
The size of the int data type depends on the system or compiler being used. Different systems or compilers may allocate different amounts of memory for the int data type. Therefore, the size of int can vary.
5.
5) Which of the following declarations is not supported in c?
Correct Answer
A. String str
Explanation
The declaration "string str" is not supported in C. In C, the string data type is not built-in, so we cannot directly declare a variable as a string. Instead, we use character arrays to represent strings in C. Therefore, the correct answer is "string str".
6.
6) For a typical program input is taken using ____________
Correct Answer
D. All of the above
Explanation
The correct answer is "All of the above" because in a typical program, input can be taken using scanf, files, or command line. The scanf function is commonly used to read input from the user during runtime. Files can be used to read input from external sources such as text files. Command line arguments can also be used to pass input to a program when it is executed. Therefore, all three options are valid methods for taking input in a typical program.
7.
7) Point out the error (if any) in the following C code?
#include<stdio.h>
enum hello
{
a,b,c;
};
main()
{
enum hello m;
printf("%d",m);
}
Correct Answer
B. Error in the statement: a,b,c;
Explanation
The error in the code is in the statement "a,b,c;". In an enum declaration, each enumerator should be separated by a comma, but the semicolon at the end is not necessary. The correct statement should be "a,b,c".
8.
8) In C language, FILE is of which data type?
Correct Answer
C. Struct
Explanation
In C language, the FILE is of the struct data type. This data type is used to define the structure of a file, which includes various attributes and information about the file such as its name, location, size, and file operations. The struct data type allows the programmer to organize and access the different elements of the file in a structured manner. Therefore, the correct answer is "struct".
9.
9) What will be the output of the following code?
#include<stdio.h>
#define square(x) x*x
void main()
{
int i;
i=64/square(4);
printf(“%d”,i);
}
Correct Answer
B. 64
Explanation
The code defines a macro `square(x)` which calculates the square of a number. In the `main` function, the variable `i` is assigned the value of `64` divided by the result of `square(4)`. Since the macro expands to `4*4`, the expression becomes `64/4*4`, which follows the left-to-right evaluation order. Therefore, the division is performed first, resulting in `16*4`, and the final value of `i` is `64`.