Home Tests Campus Placement

Campus Placement

Campus placement MCQ questions — Aptitude, Verbal, Reasoning, Technical.

2,162 Q 4 Subjects Any Graduate
Take Mock Test
Advertisement
Difficulty: All Easy Medium Hard 2091–2100 of 2,162
Subjects in Campus Placement
Q.2091 Medium Computer Knowledge 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.2092 Medium Computer Knowledge 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.2093 Medium Computer Knowledge C Programming
Which of the following is used to dynamically allocate memory in C?
A new()
B alloc()
C malloc()
D create()
Correct Answer:  C. malloc()
EXPLANATION

malloc() (memory allocation) is the standard function in C for dynamic memory allocation. It returns a void pointer to the allocated memory. The syntax is: ptr = (type*)malloc(size);

Take Test
Q.2094 Medium Computer Knowledge C Programming
What will be printed if char ch = 'A'; printf("%d", ch); is executed?
A A
B 65
C 97
D 41
Correct Answer:  B. 65
EXPLANATION

When %d format specifier is used with a char variable, it prints the ASCII value. The ASCII value of 'A' is 65. If it were 'a', the value would be 97.

Take Test
Q.2095 Medium Computer Knowledge C Programming
Which of the following correctly declares a pointer to an integer?
A int *ptr;
B *int ptr;
C ptr *int;
D int ptr*;
Correct Answer:  A. int *ptr;
EXPLANATION

The correct syntax for declaring a pointer to an integer is 'int *ptr;' where the asterisk (*) indicates that ptr is a pointer. The placement of * before the variable name is crucial.

Take Test
Q.2096 Easy Computer Knowledge C Programming
What is the purpose of the break statement in a loop?
A Pause the loop temporarily
B Exit the loop immediately
C Restart the loop
D Skip the current iteration
Correct Answer:  B. Exit the loop immediately
EXPLANATION

The break statement exits or terminates the current loop immediately. Option D describes continue (which skips to next iteration), while break actually exits the loop.

Take Test
Q.2097 Easy Computer Knowledge C Programming
In C, which operator has the highest precedence?
A Arithmetic operator
B Logical operator
C Parentheses ()
D Assignment operator
Correct Answer:  C. Parentheses ()
EXPLANATION

Parentheses have the highest precedence in C. Expressions within parentheses are evaluated first, followed by arithmetic operators, then logical operators, and finally assignment operators.

Take Test
Q.2098 Easy Computer Knowledge C Programming
Which header file is required to use the printf() function?
A #include
B #include
C #include
D #include
Correct Answer:  B. #include
EXPLANATION

The stdio.h (Standard Input Output) header file contains declarations for printf(), scanf(), and other input/output functions. It is essential for console I/O operations.

Take Test
Q.2099 Easy Computer Knowledge C Programming
What is the size of int data type in a 32-bit system?
A 2 bytes
B 4 bytes
C 8 bytes
D 1 byte
Correct Answer:  B. 4 bytes
EXPLANATION

In a 32-bit system, the int data type typically occupies 4 bytes (32 bits). This is the standard size for integer types on most 32-bit architectures.

Take Test
Q.2100 Hard Computer Knowledge C Programming
Which of the following is the correct way to pass a string to a function in C?
A void func(string s);
B void func(char s[]);
C void func(char *s);
D Both B and C
Correct Answer:  D. Both B and C
EXPLANATION

Both char s[] (array notation) and char *s (pointer notation) are valid ways to pass strings to functions in C. C does not have a built-in string type; strings are represented as character arrays or pointers to char.

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