Central Exam — Computer Knowledge
UPSC · SSC · Bank · Railway · NDA — Central Government Exam MCQ Practice
309 Questions 5 Topics Take Test
Advertisement
Showing 71–80 of 309 questions
Q.71 Medium C Programming
What will be the output of: char str[] = "Hello"; printf("%c", str[1]);?
A H
B e
C l
D o
Correct Answer:  B. e
Explanation:

Array indexing in C starts from 0. str[0]='H', str[1]='e', str[2]='l', str[3]='l', str[4]='o', str[5]='\0'. Therefore, str[1] is 'e'.

Take Test
Q.72 Medium C Programming
Which function is used to compare two strings in C?
A strcmp()
B strcomp()
C compare()
D strcmpare()
Correct Answer:  A. strcmp()
Explanation:

strcmp() is the standard library function used to compare two strings. It returns 0 if strings are equal, negative if first string is less, and positive if first string is greater. It's declared in string.h.

Take Test
Q.73 Medium C Programming
What is the output of the following: int x = 5; int *p = &x; printf("%d", *p);?
A Address of x
B 5
C Garbage value
D Error
Correct Answer:  B. 5
Explanation:

p is a pointer to x, so &x gives the address of x. *p (dereferencing) gives the value stored at that address, which is 5. The output will be 5.

Take Test
Q.74 Hard C Programming
Which of the following is an invalid identifier in C?
A myVar
B my_var
C my$var
D _myVar
Correct Answer:  C. my$var
Explanation:

In C, identifiers can only contain alphanumeric characters (a-z, A-Z, 0-9) and underscores (_), and must start with a letter or underscore. The dollar sign (\() is not allowed, making 'my\)var' invalid.

Take Test
Q.75 Hard C Programming
What will be the output of: int x = 5; printf("%d %d", x++, ++x);?
A 5 7
B 6 7
C 5 6
D 6 6
Correct Answer:  A. 5 7
Explanation:

x++ is post-increment (returns 5, then x becomes 6), ++x is pre-increment (x becomes 7, then returns 7). The order of evaluation in printf is implementation-dependent, but typically right to left, giving 5 7.

Take Test
Advertisement
Q.76 Hard C Programming
What is the difference between structure and union in C?
A Both allocate memory to all members simultaneously
B Structure allocates memory to all members; union allocates shared memory
C Union allocates memory to all members; structure allocates shared memory
D No difference
Correct Answer:  B. Structure allocates memory to all members; union allocates shared memory
Explanation:

Structure allocates separate memory for each member (total size = sum of all members). Union shares a single memory location among all members (total size = size of largest member). This is a fundamental difference in memory allocation.

Take Test
Q.77 Hard C Programming
Which of the following function declarations is correct for a function that takes no parameters and returns no value?
A void function(void);
B void function();
C null function(void);
D void function(null);
Correct Answer:  A. void function(void);
Explanation:

The correct syntax is 'void function(void);' where 'void' in parentheses explicitly states no parameters. Option B is also valid in C (defaults to no parameters), but option A is more explicit and portable across C standards.

Take Test
Q.78 Hard C Programming
In C, what is the purpose of the typedef keyword?
A Define a new data type
B Create an alias for existing data types
C Declare type of variables
D Convert one data type to another
Correct Answer:  B. Create an alias for existing data types
Explanation:

typedef creates an alias (synonym) for existing data types. For example, 'typedef int Integer;' creates 'Integer' as an alias for 'int'. This improves code readability and portability. It doesn't create entirely new types, but provides alternative names.

Take Test
Q.79 Easy C Programming
In C programming, which of the following is NOT a valid data type?
A int
B float
C string
D double
Correct Answer:  C. string
Explanation:

In C, 'string' is not a primitive data type. C uses 'char' arrays to represent strings. The valid primitive data types are int, float, double, char, void, and their variants.

Take Test
Q.80 Easy C Programming
What will be the output of: int a = 10; int b = 20; int c = a + b; printf("%d", c);?
A 10
B 30
C 20
D Error
Correct Answer:  B. 30
Explanation:

Variable 'a' is initialized to 10, 'b' is initialized to 20. When c = a + b, c becomes 10 + 20 = 30. Therefore, printf outputs 30.

Take Test
IGET
iget AI
Online · Ask anything about exams
Hi! 👋 I'm your iget AI assistant.

Ask me anything about exam prep, MCQ solutions, study tips, or strategies! 🎯
UPSC strategy SSC CGL syllabus Improve aptitude NEET Biology tips