1.
Who is the father of C programming?
Correct Answer
A. Dennis Ritchie
Explanation
Dennis Ritche - inventor of C programming language and co-developer of Unix; Linus Torvalds - developed a Unix-like operating system, LINUX; Charles Babbage - father of Computer; Bill Gates - co-founder of Microsoft Corporation;
2.
Which of the following is a C language compiler?
Correct Answer
C. Turbo C/C++
Explanation
AutoCAD - Computer-aided Designing of Electrical/Electronics circuit and Civil/mechanical models; Adobe Acrobat - view, create, manipulate, print and manage files in Portable Document Format; Turbo C/C++ - Compiler for C and C++ program; MS Powerpoint - Used for presenting Presentation by using wide variety of effects and animations
3.
C uses a:-
Correct Answer
A. Compiler
Explanation
Compiler - transforms code written in a high-level programming language into the machine code, at once, before program runs. Interpreter - coverts each high-level program statement, one by one, into the machine code, during program run.
4.
Which choice indicates a single-line comment?
Correct Answer
B. //single line comment
Explanation
The correct answer is "//single line comment" because in many programming languages, including C++, Java, and Python, the double forward slash "//" is used to indicate a single-line comment. This means that any text written after "//" on the same line is ignored by the compiler or interpreter. In contrast, "##" is typically used for comments in some scripting languages like Perl, while "#single line comment" would be interpreted as a regular line of code.
5.
Which function copies one string over another
Correct Answer
C. Strcpy()
Explanation
strcat() is used to append or join two strings. strcmp() is used to compare two strings. strcpy() is used to copy one string over another. strlen() is used to get the length of the string.
6.
C programs must have at least one function named main():
Correct Answer
A. True
Explanation
C programs must have at least one function named main() because the main() function is the entry point of the program. It is where the program starts executing and from where other functions can be called. Without a main() function, the program would not have a starting point and therefore cannot be executed.
7.
How many times does the following loop run?
for(int i=0;i<5;i++)
{statement;}
Correct Answer
C. 5
Explanation
1) :- i=0; 2) :- i=1; 3) :- i=2; 4) :- i=3; 5) :- i=4; 6th time 5<5 : which is false. Therefore, it exits the loop
8.
Importing "math" header file lets the user use
Correct Answer
A. Sqrt()
Explanation
sqrt() which finds square root of the argument can be used after importing math header file. getch() which fetches a single char from user and clrscr() clears the output screen, they can be used after importing conio header file. printf() which prints the argument in output screen can be used after importing stdio header file.
9.
What does "static" variable storage class does?
Correct Answer
B. Doesn't allow the variable to change it's value throughout the program
Explanation
The "static" variable storage class doesn't allow the variable to change its value throughout the program. Once a static variable is initialized, its value remains the same until the program terminates. This is because static variables are allocated memory only once and retain their values between function calls. They are commonly used when a variable needs to maintain its value across multiple function calls or when we want to limit the scope of a variable to a specific function.
10.
What is the function of "#define"
Correct Answer
A. Value cannot be changed by your program code
Explanation
The function of "#define" is to create a constant value that cannot be changed by the program code. This allows the programmer to define a value once and use it throughout the program without the risk of accidentally modifying it. It is commonly used for defining constants such as mathematical values or configuration settings.
11.
What is the output of the following program?
#include
main()
{
int x,y,z=0;
//float y;
y = 3;
x = 7;
y+=2;
z=y+x;
printf("x=%d z=%d", x, z);
}
Correct Answer
A. 7 12
Explanation
The program initializes three variables: x, y, and z. The value of y is set to 3 and the value of x is set to 7. Then, y is incremented by 2, resulting in a value of 5. Finally, z is assigned the sum of y and x, which is 5 + 7 = 12. The printf statement prints the values of x and z, which are 7 and 12 respectively.
12.
Which of the following are not a keyword?
[One or more options correct]
Correct Answer(s)
B. Java
C. Help
Explanation
The keywords in programming languages are reserved words that have a specific meaning and cannot be used as identifiers. In this case, "java" is not a keyword because it can be used as an identifier for variables, classes, or methods. Similarly, "help" is also not a keyword as it can be used as an identifier. However, "break" and "float" are keywords in Java and cannot be used as identifiers.
13.
Which of the following is a relational operator?
Correct Answer
B. !=
Explanation
The correct answer is !=. This is a relational operator used to check if two values are not equal to each other. It returns true if the values are not equal, and false if they are equal.
14.
What is the output of the following program?
#include
main()
{
int x;
float y;
y = x = 7.5;
printf("x=%d y=%f", x, y);
}
Correct Answer
A. X=7 y=7.000000
Explanation
‘x’ gets the integral value from 7.5 which is 7 and then 'y' get the value from 'x' which is now 7. 'x' gets 7 instead of 7.5 because 'x' is an integer. y gets the value of 'x' which is 7. Since, 'y' is float, y=7.000000 Therefore, x=7 y=7.000000
15.
The ________ operator is used with a pointer to de-reference the address contained in the pointer.
Correct Answer
*
Explanation
The * operator is used with a pointer to de-reference the address contained in the pointer. This means that it allows access to the value stored at the memory address pointed to by the pointer. By using the * operator, we can retrieve the value stored at that address and manipulate it as needed.
16.
What will be the output of the following c program?
#include
int main(){
int goto=5;
printf("%d",goto);
return 0;
}
Correct Answer
C. Compilation error
Explanation
Compilation error. Invalid variable name. goto is keyword in c. variable name cannot be any keyword of c language.
17.
Which of the following statement is incorrect?
Correct Answer
C. Except underscore and ampersand no other special symbol are allowed in the middle of the variable declaration.
Explanation
Ampersand(&) is not allowed to be used in variable name.
18.
Count the total number of errors(if any):-
#include<stdio.h>
int main(){
int i;
for(i=0;i=<5;i++);
printf("%d",i)
return 0;
}
Correct Answer
D. 3
Explanation
3 errors. [1]relational operator in condition should be <= instead of =< [2]after 'for' statement semi-colon(;) is present [3]after print statement semi-colon isn't present
19.
An array can be initialized at either compile time or at ________
Correct Answer
runtime, run time
Explanation
An array can be initialized at either compile time or at runtime. This means that the array can be assigned values either when the program is being compiled or during the execution of the program. The choice of when to initialize the array depends on the specific requirements and needs of the program.
20.
When initializing a multidimensional array, not specifying all its dimensions is an error.
Correct Answer
A. True
Explanation
When initializing a multidimensional array, it is necessary to specify all its dimensions. If any dimension is not specified, it will result in an error. This is because each dimension represents a specific level of the array, and not specifying a dimension would create ambiguity in the array's structure. Therefore, it is important to provide the correct number of dimensions and their sizes when initializing a multidimensional array.
21.
Which loop executes the statement within the loop at least one time?
[One or more options may be correct]
Correct Answer
B. Do...while loop
Explanation
do...while
As the condition is checked at the end of the loop, it is also know as exit-controlled loop.
22.
The C standard function that receives a single character from the keyboard is ________
Correct Answer
getch,getch(),getchar,getchar()
Explanation
The C standard function that receives a single character from the keyboard is either getch or getchar. Both functions can be used to read a single character from the keyboard, with getch being a non-standard function and getchar being a standard function. The use of parentheses after the function name (getch() or getchar()) is optional.
23.
The expression !(x<=y) is same as the expression x>y.
Correct Answer
A. True
Explanation
The expression !(x
24.
)What would be the output of the program:-
#include
main()
{
int a[] = {2,1};
printf("%d", a[1]);
}
Correct Answer
B. 1
Explanation
1
The index value of array a over here is '1'
The first element has index value '0' and the second element has index value '1'.
Therefore, a[1]=1
25.
Can we replace any "switch" statement with "if..else" statement?
Correct Answer
A. Yes
Explanation
Yes, we can replace any "switch" statement with an "if..else" statement. Both "switch" and "if..else" statements are used for making decisions based on certain conditions. The "switch" statement allows multiple conditions to be checked, while the "if..else" statement allows for more complex conditions and multiple conditions to be checked as well. Therefore, it is possible to replace a "switch" statement with an equivalent "if..else" statement.
26.
Can we replace any "if..else" statement with "switch" statement?
Correct Answer
B. No
Explanation
No
For instance,
"if (a>0 && a
27.
Find the output of the following program:-
#include
main()
{
int i = 1;
while(++i <= 5)
printf("%d ",++i);
}
Enter the output here ________
Correct Answer
3 5,35
Explanation
3 5
| i | ++i | i
28.
Find the output of the following program:-
#include
int main()
{
static int i = 10;
auto int x = i;
if (x==i)
printf("x and i are Equal\n");
else
printf("x and i are Unequal\n");
return 0;
}
Enter the output here ________
Correct Answer
x and i are Equal
Explanation
Variable Storage Classes:-
static is declared then the value of the variable doesn't change during runtime whereas auto lets the value change during runtime.
Since there is no operation that is trying to change the value of the variables so, it's just a comparison of both the variables.