1.
An array Index starts with.?
Correct Answer
B.
0
Explanation
The correct answer is 0. In most programming languages, arrays are zero-indexed, meaning that the first element of an array has an index of 0. This means that if we have an array with n elements, the indices will range from 0 to n-1.
2.
What is the output of C Program.?
int main()
{
int a[];
a[4] = {1,2,3,4};
printf("%d", a[0]);
}
Correct Answer
D.
Compiler error
Explanation
The given code will result in a compiler error. This is because the array "a" is declared without a size, which is not allowed in C. The size of the array needs to be specified when declaring it.
3.
What is the output of C Program.?
int main()
{
int a[] = {1,2,3,4};
int b[4] = {5,6,7,8};
printf("%d,%d", a[0], b[0]);
}
Correct Answer
A.
1,5
Explanation
The output of the given C program is "1,5". This is because the program declares two arrays, "a" and "b", and initializes them with different values. The printf statement then prints the first elements of both arrays, which are 1 from array "a" and 5 from array "b".
4.
What is the output of C program.?
int main()
{
char grade[] = {'A','B','C'};
printf("GRADE=%d, ", *grade);
printf("GRADE=%d", grade[0]);
}
Correct Answer
C.
65,65
Explanation
The program declares a character array called "grade" and initializes it with the values 'A', 'B', and 'C'. The first printf statement prints the value of the first element of the array using the dereference operator (*grade), which is the ASCII value of 'A', which is 65. The second printf statement prints the value of the first element of the array using the index notation (grade[0]), which again is the ASCII value of 'A', which is 65. Therefore, the output of the program is "GRADE=65, GRADE=65".
5.
What is the output of C program.?
int main()
{
int a[3] = {10,12,14};
int i=0;
while(i<3)
{
printf("%d ", i[a]);
i++;
}
}
Correct Answer
C.
10, 12, 14
Explanation
The program initializes an integer array 'a' with values 10, 12, and 14. It then enters a while loop that runs as long as the variable 'i' is less than 3. Inside the loop, it prints the value of 'i[a]', which is equivalent to 'a[i]'. Since 'i' starts at 0 and increments by 1 each iteration, the program prints the values of 'a' in order: 10, 12, 14. Therefore, the output of the program is "10, 12, 14".
6.
What is the output of C program with arrays.?
int main()
{
int a[3] = {20,30,40};
int b[3];
b=a;
printf("%d", b[0]);
}
Correct Answer
D.
Compiler error
Explanation
The given program will result in a compiler error. This is because arrays cannot be assigned to each other directly in C. The line "b=a;" is trying to assign the array "a" to the array "b", which is not allowed.
7.
What is the output of C program with arrays.?
int main()
{
int ary(3)=[20,30,40];
printf("%d", a(1));
}
Correct Answer
D.
Compiler error
Explanation
The given C program has a compiler error. The correct way to declare and initialize an array in C is by using square brackets [], not parentheses (). Therefore, the line "int ary(3)=[20,30,40];" should be changed to "int ary[3]={20,30,40};".
8.
What is the output of C program with arrays.?
int main()
{
char grade={'A','B','C'};
printf("%c", grade[0]);
}
Correct Answer
D.
Compiler error
Explanation
The given C program will result in a compiler error. This is because the array "grade" is declared as a character array but it is initialized with multiple characters instead of a string. In C, a string should be enclosed in double quotes. Therefore, the correct way to initialize the array would be: char grade[] = "ABC";
9.
What is the need for C arrays.?
Correct Answer
D.
All the above.
Explanation
The need for C arrays is to avoid creating multiple separate variables and getting confused while using them. With a single array variable, all elements of the array can be easily accessed. This improves code maintainability for programmers and maintainers. Therefore, the correct answer is "All the above."
10.
What is a multidimensional array in C Language.?
Correct Answer
D.
All of these
Explanation
A multidimensional array in C Language is an array of arrays. It is like a matrix or table with rows and columns. To access a specific element in the array, the index starts from 0 for both rows and columns. Therefore, to access the element in the 3rd row and 2nd column, the index would be ary[2][1]. So, the correct answer is "All of these" as all the statements mentioned in the options are true about a multidimensional array in C Language.
11.
What is the function used to allocate memory to an array at run time without initializing array elements.?
Correct Answer
B.
malloc()
Explanation
The function used to allocate memory to an array at run time without initializing array elements is malloc(). This function is used in C programming language to dynamically allocate memory for a specified number of bytes. It returns a pointer to the allocated memory, which can then be used to access and manipulate the array elements. Unlike calloc(), malloc() does not initialize the allocated memory to zero.
12.
What is the dimension of the C array int ary[10][5].?
Correct Answer
B. 2
Explanation
The dimension of the C array int ary[10][5] is 2. This is because the array has two dimensions - the first dimension has a size of 10 and the second dimension has a size of 5.
13.
What is the dimension of the below C Array.? int ary[]={1,3,5,7};
Correct Answer
A. 1
Explanation
The dimension of the given C array is 4. This is because the array "ary" contains 4 elements: 1, 3, 5, and 7.
14.
Difference between C Arrays, ary[10] and cry[10][10] is.?
Correct Answer
A.
ary[10] is a single dimensional array. cry[10][10] is a Multidimensional array.
Explanation
The correct answer is that ary[10] is a single dimensional array and cry[10][10] is a multidimensional array. This is because ary[10] is declared as a one-dimensional array with a size of 10, while cry[10][10] is declared as a two-dimensional array with dimensions of 10 by 10.
15.
Choose correct C while loop syntax.
Correct Answer
A.
while(condition)
{
//statements
}
Explanation
The correct answer is "while(condition) { //statements }" because this is the standard syntax for a while loop in C. The loop will continue executing as long as the condition is true, and the statements inside the loop will be executed repeatedly until the condition becomes false.
16.
A function which calls itself is called a ___ function.
Correct Answer
C.
Recursive Function
Explanation
A function which calls itself is called a recursive function.
17.
Choose correct statement about Functions in C Language.
Correct Answer
D. All of these
Explanation
The correct answer is "All of these". This means that all of the statements provided are correct about Functions in C Language. A function is a group of C statements that can be reused multiple times. Every function has a return type, and every function may or may not return a value.
18.
How many values can a C Function return at a time.?
Correct Answer
A.
Only One Value
Explanation
A C function can only return one value at a time. This is because C does not support multiple return values. If a function needs to return multiple values, it can use pointers or structures to achieve that.
19.
Every C Program should contain which function.?
Correct Answer
D.
main()
Explanation
The correct answer is "main()". In C programming, every program should contain a main() function. This function is the entry point of the program and is executed first when the program is run. It is mandatory to have a main() function in every C program.
20.
What is the minimum number of functions to be present in a C Program.?
Correct Answer
A. 1
Explanation
A C program must have at least one function, which is the main function. The main function is the entry point of the program and it is where the execution of the program begins. Without the main function, the program cannot be executed. Therefore, the minimum number of functions required in a C program is 1.
21.
Arguments received by a function in C language are called ___ arguments.
Correct Answer
B.
Formal arguments
Explanation
Formal arguments are the arguments received by a function in C language. These arguments are declared in the function prototype and function definition. They act as placeholders for the actual arguments that are passed to the function when it is called.
22.
Choose a non Library C function below.
Correct Answer
D.
printf2()
Explanation
The function printf2() is not a standard C library function. It is not included in the standard C library and is not recognized by the compiler. Therefore, it is a non-library C function.
23.
What do you call this C Function calling itself.?
int funny2()
{
funny2(num);
}
Correct Answer
D.
Recursive Function
Explanation
The given C function is calling itself, which is known as recursion. Recursion is a process in which a function calls itself as a subroutine. Therefore, the correct answer is "Recursive Function".
24.
What are types of Functions in C Language.?
Correct Answer
C.
Both Library and User Defined
Explanation
The correct answer is "Both Library and User Defined". In C language, there are two types of functions - library functions and user-defined functions. Library functions are built-in functions provided by the C programming language and are stored in libraries. These functions can be directly used in a program without the need for any additional code. User-defined functions, on the other hand, are created by the programmer to perform specific tasks. These functions are defined and implemented by the programmer and can be reused multiple times in the program.
25.
Array of Arrays is also called.?
Correct Answer
C.
Multi Dimensional Array
Explanation
An array of arrays is also known as a multi-dimensional array. This type of array allows for the organization of data in multiple dimensions, such as rows and columns. Each element in a multi-dimensional array can be accessed using multiple indices. This type of array is commonly used in programming languages to represent matrices or tables of data.