1.
C programming language was developed in 1972 by ________________ at bell laboratories of AT&T (American Telephone & Telegraph).
Correct Answer
C. Dennis Ritchie
Explanation
Dennis Ritchie is the correct answer because he was one of the key developers of the C programming language. Along with Ken Thompson, he created C at Bell Laboratories in 1972. Ritchie's contributions to C were instrumental in its development and popularization, making it one of the most widely used programming languages today.
2.
Which of the following special symbol can be used in a variable name?
Correct Answer
D. _ (underscore)
Explanation
The underscore symbol can be used in a variable name. In many programming languages, including Python and JavaScript, the underscore is allowed as a character in variable names. It is commonly used to separate words in a multi-word variable name, creating a more readable and understandable code. For example, a variable could be named "my_variable" or "user_name".
3.
#include<stdio.h>
int main()
{
int a;
printf("%d\n", sizeof(a));
return 0;
}
What is the output of the program?
Correct Answer
C. Compiler Dependent
Explanation
The output of the program is "Compiler Dependent". The sizeof() function in C returns the size in bytes of its operand. However, the size of an int data type is not fixed and can vary depending on the compiler and the system being used. Therefore, the output of sizeof(a) can be different on different compilers or systems.
4.
#include<stdio.h>
int main()
{
int n;
for(n = 1; n!=8; n++)
{
printf("n = %d", n--);
}
return 0;
}
How many times will the loop run?
Correct Answer
D. Infinite Times
Explanation
The loop will run infinitely because the statement `n--` in the `printf` function will decrement the value of `n` after it is printed. As a result, the condition `n!=8` will always be true, causing the loop to continue indefinitely.
5.
C can be used on ?
Correct Answer
D. All of these
Explanation
C is a programming language that is highly versatile and can be used on multiple operating systems. It is compatible with DOS, Linux, and Windows, making it a widely used language across different platforms. Therefore, the correct answer is "All of these" as C can be used on all of these operating systems.
6.
Which of the following are incorrect statements? If int a=10.
1) if( a==10 ) printf("Hello");
2) if( 10==a ) printf("Hello");
3) if( a=10 ) printf("Hello");
4) if( 10=a ) printf("Hello");
Correct Answer
A. Only 4
Explanation
The correct answer is "Only 4". This is because the statement "if( 10=a )" is incorrect syntax in C programming. In C, the assignment operator is "=", not "==". Therefore, the correct syntax should be "if( a=10 )". The other statements are correct and will print "Hello" if the condition is true.
7.
Is ["For Boolean Variable, Zero is used to represent false, and One is used to represent true."] true or false?
Correct Answer
A. True
Explanation
This statement is true. In Boolean logic, which is used in computer programming and digital electronics, the value of zero is used to represent false, while the value of one is used to represent true. This convention allows for logical operations and comparisons to be performed on Boolean variables.
8.
What will be the output of following program ?
#include <stdio.h>
void main()
{
if(!printf(""))
printf("Okkk");
else
printf("Hiii");
}
Correct Answer
A. Okkk
Explanation
The program first checks the condition inside the if statement, which is the output of the printf function. The printf function prints an empty string and returns the number of characters printed. In this case, since the string is empty, it returns 0. The condition in the if statement is "!0", which evaluates to true. Therefore, the code inside the if statement is executed and "Okkk" is printed.
9.
#include <stdio.h>
void main()
{
int x=22;
if(x=10)
printf("TRUE");
else
printf("FALSE");
}
Correct Answer
B. True
Explanation
The correct answer is "True" because the condition in the if statement is "x=10", which is an assignment statement. In C programming, the value of an assignment statement is the value assigned to the variable, which in this case is 10. Since 10 is considered as a true value, the code inside the if statement will be executed, resulting in the output "True".
10.
#include
int main()
{ int a=5;
if(a)
printf("1");
printf("2");
else
printf("3");
printf("4");
return 0;
}
Correct Answer
D. ERROR (misplaced if/illegal else without matching if.)
Explanation
The given code will result in an error because the if statement is not properly structured. The if statement is missing curly braces {}, so only the first printf statement is considered as part of the if statement. The second printf statement is outside of the if statement, which causes a syntax error. Additionally, the else statement does not have a corresponding if statement, which is also a syntax error. Therefore, the code will not compile and will result in an error.