1.
What statement can print \n on screen?
Correct Answer
A. Printf("\\n");
Explanation
The correct answer is `printf("");`. This statement uses the `printf` function to print the string `""` on the screen. The backslash `\` is used to escape the forward slash `/` character, so it is printed as part of the string.
2.
Pointers are variables that store addresses in memory. Which of the following statements best describes what a pointer variable represents?
Correct Answer
A. An address in memory
Explanation
The address stored in a pointer variable is of type int because pointers store memory addresses, which are represented as integers.
3.
What is the output of the following code?
Correct Answer
C. Segmentation fault/code trash
Explanation
This error message typically occurs when a program tries to access memory that it doesn't have permission to access. In this specific case, the line foo(&p); is the culprit.
4.
What will be printed?
int a = 15;
int b = 0;
b = (a % 7);
printf("\n\n%i\n", b);
Correct Answer
B. 1
Explanation
The code calculates the remainder of dividing 15 by 7 using the modulus operator (%). Since the remainder is 1, the value of b will be 1. The printf statement will then print the value of b, which is 1.
5.
The operators . , !! , < , = if arranged in ascending order of precedence reads?
Correct Answer
C. =,!!,<,.
Explanation
The answer =, !!,
6.
Pain:Misery::?
Correct Answer
D. Despair:lonliness
Explanation
"despair: loneliness" suggests that "despair" leads to "loneliness," which is a similar cause-and-effect relationship as "Pain: Misery."
7.
A clock is so placed that at 12 noon its minutes hand points towards north-east, in which direction does its hour hand points at 1.30p.m?
Correct Answer
C. South
Explanation
To determine the direction in which the hour hand points at 1:30 PM, given that the minute hand points towards the north-east at 12 noon, follow these steps:
Understand the initial orientation:
At 12 noon, the minute hand points north-east.
The hour hand at 12 noon will point in the same direction as the minute hand, which is north-east.
Determine the movement of the hour hand:
Each hour represents a 30-degree movement of the hour hand (since the clock face is 360 degrees and there are 12 hours on a clock, 360 degrees / 12 hours = 30 degrees per hour).
At 1:00 PM, the hour hand moves 30 degrees clockwise from its position at 12:00 noon.
At 1:30 PM, the hour hand will move an additional 15 degrees (since 30 minutes is half of an hour, and 30 degrees / 2 = 15 degrees).
Calculate the total movement from 12 noon to 1:30 PM:
Total movement = 30 degrees (from 12:00 to 1:00) + 15 degrees (from 1:00 to 1:30) = 45 degrees.
Determine the final direction:
Since the initial direction at 12 noon is north-east, moving 45 degrees clockwise from north-east will point towards south.
Therefore, at 1:30 PM, the hour hand will point towards the south.
8.
Number of letters skipped in between adjacent letters in the series is in the order of 12 ,22,32 . which of the following series observes the above rule
Correct Answer
A. CEJT
Explanation
The correct answer is CEJT because the number of letters skipped in between adjacent letters follows the pattern of increasing by 10 each time. In CEJT, the letters C and J have 12 letters skipped in between, while the letters J and T have 22 letters skipped in between. Therefore, the next letter in the series should have 32 letters skipped in between, which is consistent with the pattern observed in CEJT.
9.
Which one of the four equations will be correct?
given interchanges: signs "-" and "*" , numbers 3 and 6.
Correct Answer
C. 3-6*8=10
10.
In a row of 10 boys, when Rohith was shifted by 2 places towards the left he became 7th from the left end what was his earlier position from the right end of the row?
Correct Answer
B. 0
Explanation
Let's analyze the information given:
1. Originally, Rohith was in a row of 10 boys.
2. When Rohith was shifted by 2 places towards the left, he became the 7th from the left end.
We can find Rohith's original position from the right end of the row using this information.
Originally, there were 10 boys in the row, and Rohith became the 7th from the left end after shifting 2 places to the left. So, originally, he was the 10th boy from the left end.
To find his original position from the right end, you can subtract his position from the total number of boys in the row:
Position from the right end = Total number of boys - Position from the left end
Position from the right end = 10 - 10
Position from the right end = 0
So, Rohith's earlier position from the right end of the row was 0 (he was the rightmost boy).
11.
4,23,60,121,___?
Correct Answer
212
Explanation
The given sequence starts with 4 and each subsequent number is obtained by adding the square of the position of the number in the sequence. For example, 4 + 1^2 = 5, 23 + 2^2 = 27, 60 + 3^2 = 69, and so on. Therefore, the missing number in the sequence would be 121 + 4^2 = 121 + 16 = 137. However, this is not the given answer. It seems that the given answer of 212 does not follow the pattern of the sequence and is incorrect.
12.
A B C D E F G H I J K L M
N O P Q R S T U V W X Y Z
Which letter should be 9th letter to the left of 9th letter from the right if the first half of the given alphabets is reversed
Correct Answer
B. E
Explanation
If the first half of the given alphabets is reversed, the sequence becomes M L K J I H G F E D C B A N O P Q R S T U V W X Y Z. Counting 9 letters from the right, we reach the letter R. Counting 9 letters to the left of R, we reach the letter E. Therefore, the letter E should be the 9th letter to the left of the 9th letter from the right.
13.
Umbrella is to rain
what goggles are to?
Correct Answer
C. Sun
Explanation
Just as an umbrella is used as protection from rain, goggles or sunglasses are used as protection from the sun and its intense light and glare. This analogy highlights the protective function of goggles in response to the sun, making option C, "sun," the correct choice.
14.
Odd man out.
Correct Answer
B. Basketball
Explanation
The odd man out in this group is basketball because it is the only sport that is played with a round ball, while the other three sports (billiards, snookers, and table tennis) are played with balls that are not round.
15.
According to ANSI specifications which is the correct way of declaring main when it receives command-line arguments?
Correct Answer
A. Int main(int argc,char *argv[])
Explanation
The correct way of declaring main when it receives command-line arguments is "int main(int argc,char *argv[])". This declaration follows the ANSI specifications, where "argc" represents the number of command-line arguments passed to the program, and "argv" is an array of strings containing the actual arguments. This declaration allows the program to access and process the command-line arguments effectively.
16.
Char *s[10] defines an array of ___________
Correct Answer
C. Pointers to strings
Explanation
The declaration "char *s[10]" defines an array of pointers to strings. Each element in the array "s" is a pointer that can point to a string. The size of the array is 10, meaning it can hold 10 pointers to strings.
17.
Which header file should be included to use functions like malloc() and calloc()?
Correct Answer
C. Stdlib.h
Explanation
To use functions like malloc() and calloc(), the header file that should be included is stdlib.h. This header file contains the declarations for various standard library functions, including memory allocation functions like malloc() and calloc(). By including this header file, the program can access these functions and use them for dynamic memory allocation.
18.
What gets printed?
printf("%d\n",4 ?:8);
Correct Answer
D. Compiler error
Explanation
The code will result in a compiler error because the conditional operator (?:) requires three operands: a condition, a value if the condition is true, and a value if the condition is false. In this case, there is no condition provided before the question mark, resulting in a syntax error.
19.
1 11 21 1211 111221 ________
Correct Answer
B. 312211
Explanation
The given sequence follows a pattern where each number describes the count of consecutive digits in the previous number. Starting with 1, there is 1 digit, so the next number is 11. In 11, there are 2 consecutive digits, so the next number is 21. In 21, there is 1 digit followed by 1 digit, so the next number is 1211. Continuing this pattern, the next number would be 312211, where there are 3 ones, followed by 2 twos, followed by 1 one.
20.
Which keyword is used for coming out of recursion?
Correct Answer
B. Return
Explanation
The keyword "return" is used for coming out of recursion. In a recursive function, when a condition is met, the function can return a value and terminate the current call, allowing the program flow to return to the previous call. This is essential to prevent infinite recursion and to ensure that the function completes its task and returns the desired result. The "return" keyword allows the function to pass control back to the calling function and exit the recursion.
21.
What is the output of the following?
Correct Answer
C. Compile time error
Explanation
The given code does not provide any context or code logic to suggest what the expected output should be. However, based on the given options, it is likely that the code would result in a compile time error. This could be due to various reasons such as missing semicolons, incorrect syntax, or undefined variables. Without further information, it is not possible to determine the exact reason for the compile time error.
22.
How many tokens are there in the following? if(csi==100);
Correct Answer
B. 7
Explanation
The given code snippet contains 7 tokens. The tokens are: "if", "(", "csi", "==", "100", ")", and ";".
23.
C programming:the given expression P-=Q+1 is same as
Correct Answer
A. P=P-Q-1
Explanation
The given expression P-=Q+1 is the same as P=P-Q-1. The "-=" operator is used to subtract the value on the right-hand side from the variable on the left-hand side and assign the result back to the variable. Therefore, P-=Q+1 is equivalent to P=P-(Q+1), which simplifies to P=P-Q-1.
24.
A pointer is a C which has not been initialized is know as:
Correct Answer
D. Wild pointer
Explanation
A wild pointer is a pointer in C that has not been initialized or assigned a valid memory address. It points to a random or unpredictable memory location, which can result in unexpected behavior or program crashes when accessed.
25.
Which of the following does not represent a valid storage class in C?
Correct Answer
B. Union
Explanation
In C, static, extern, and automatic are valid storage classes. However, union is not a storage class in C. It is a data type that allows storing different types of data in the same memory location. Therefore, union does not represent a valid storage class in C.
26.
When fopen() is not able to open a file, then it returns
Correct Answer
A. Compiler dependent
Explanation
The return value of fopen() when it is not able to open a file is compiler dependent, meaning it can vary depending on the compiler being used. Different compilers may handle this situation differently, so the specific return value cannot be determined universally.
27.
How will you free the allocated memory?
Correct Answer
B. Free(var-name);
Explanation
The correct answer is "free(var-name)". This is because the "free()" function is used in C programming to deallocate the memory that was previously allocated using functions like "malloc()" or "calloc()". By using "free(var-name)", the memory allocated to the variable "var-name" will be released and made available for other uses.
28.
What will be x in the following c code?
#include
void main()
{
int x;
}
Correct Answer
A. Integer variable
Explanation
In the given C code, x is an integer variable that has been declared but not initialized. Its value is indeterminate and could be anything, as it will contain whatever data was previously at that memory location. It’s generally a good practice to initialize variables when you declare them to avoid any unexpected behavior. For example, you could modify the code to int x = 0; to initialize x with a value of 0.
29.
Which of the following cannot be static in C?
Correct Answer
D. None
Explanation
All of the options - variables, structures, and functions - can be declared as static in C. The "none" option implies that there is no element in the given list that cannot be static. Therefore, the correct answer is "none".
30.
What is the output of the following?
#include
int main()
{
char ch;
if(ch = printf(""))
printf("It matters\n");
else
printf("It doesn't matters\n");
return 0;
}
Correct Answer
B. It doesn’t matters
Explanation
The output of the code is "It doesn't matters". This is because the if statement is checking the result of the printf function, which is the number of characters printed. Since the printf function is given an empty string as an argument, it doesn't print anything and returns 0. Therefore, the condition in the if statement is false and the else block is executed, resulting in the output "It doesn't matters".
31.
How many times is Hello world printed ?
int main()
{
fork();
fork();
printf("Hello world\n");
}
Correct Answer
C. 4
Explanation
The correct answer is 4 because there are two fork() calls in the code. Each fork() call creates a new process, so the code will be executed by a total of 4 processes. Each process will print "Hello world" once, resulting in a total of 4 "Hello world" prints.
32.
What is the output of this C code?
void main()
{
int i, j;
for(i=0,j=0;i<10,j<20;i++,j++){
printf("i=%d \t j=%d\n", i, j);
}
}
Correct Answer
A. Print i and j till 19
Explanation
The given code contains a for loop that iterates as long as i is less than 10 and j is less than 20. Inside the loop, the values of i and j are printed. Since both i and j start from 0 and increment by 1 in each iteration, the loop will execute 10 times and print the values of i and j from 0 to 9 and 0 to 19 respectively. Therefore, the output of the code will be to print i and j till 19.
33.
What is the output of this C code?
#include
int main()
{
int y = 2;
int z = y +(y = 10);
printf("%d\n", z);
}
Correct Answer
C. 20
Explanation
The code snippet assigns the value of 2 to the variable y and then adds the value of y (which is 2) to the value of y (which is 10 after the assignment). This results in z being assigned the value of 12. However, the printf statement prints the value of z, which is 12. Therefore, the output of the code is 12.
34.
Which of the following is not a standard C Library?
Correct Answer
D. Retarg.h
Explanation
The standard C Library provides a set of functions and headers that are commonly used in C programming. The headers errno.h, setjmp.h, and signal.h are all part of the standard C Library. However, retarg.h is not a standard C Library header.
35.
Which one of the following is not a prime number?
Correct Answer
D. 91
Explanation
A prime number is a number that is only divisible by 1 and itself. Among the given options, 91 is not a prime number because it is divisible by 7 and 13 in addition to 1 and 91. Therefore, 91 is the correct answer as it does not meet the criteria of being a prime number.
36.
If one-third of one-fourth of a number is 15, then three-tenth of that number is:
Correct Answer
D. 54
Explanation
If one-third of one-fourth of a number is 15, it means that one-fourth of the number is 45 (since 15 multiplied by 3 is 45). To find three-tenths of that number, we multiply 45 by 3 and divide by 10. This gives us 135 divided by 10, which equals 13.5. However, since the options only include whole numbers, we round up to the nearest whole number, which is 14. Therefore, the correct answer is 54.
37.
Which of the following is a prime number ?
Correct Answer
D. 97
Explanation
97 is a prime number because it is only divisible by 1 and itself. It does not have any other factors.