Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

1. Which of these best describes an array?

A. A data structure that shows a hierarchical behaviour


B. Container of objects of similar types
C. Arrays are immutable once initialised
D. Array is not a data structure

2. In C Programming, If we need to store word “INDIA” then syntax is as below –


char name[];
name = “INDIA”
A. char name[6] = {'I','N','D','I','A'};
B. char name[6] = {'I','N','D','I','A','\0'}
C. char name[6] = {"I","N","D","I","A"}
D. name = "INDIA"
3. In an array int arr[12] the word arr represents the _________ of the array
4. What would happen if you put too few elements in an array when you initialize it?
a) nothing
b) possible system malfunction
c) error message from the compiler
d) unused elements will be filled with 0’s or garbage

5. What is the output of the following code?


main()
{
int a[4] = {1,5};
printf(“%d”,a[3]);

}
A. 0
B. Syntax error
C. 5
D. 3

6. Array can be considered as set of elements stored in consecutive memory locations but
having __________.
A. Same data type
B. Different data type
C. Same scope
D. None of these
7. Which of the following function is more appropriate for reading in a multi-word string?
A. scanf()
B. printf()
C. gets()
D. puts()

8. Length of the string "letsfindcourse" is


A. 13
B. 14
C. 15
D. 12

9. If the two strings are identical, then strcmp() function returns


A. -1
B. 1
C. 0
D. None

10. Which of the following gives the memory address of the first element in array foo, an
array with 10 elements?
A. foo
B. &foo
C. foo[0]
D. &foo[0]

11. An array elements are always stored in ________ memory locations?


A. Sequential
B. Random
C. Sequential and Random
D. None of the above

12. What is the output of this program?


void main()
{
int arr[10];
printf("%d %d", arr[4], arr[0]);
}
A. 0 0
B. Garbage value 0
C. Garbage value Garbage value
D. Compilation Error
13. What is the output of this program?
#include<stdio.h>
#include<string.h>
void main()
{
char s1[20] = "Hello", s2[10] = " World";

printf("%s", strcpy(s2, strcat(s1, s2)));

}
A. Hello World
B. HelloWorld
C. Hello
D. World

14. What is the output of this program?


#include<stdio.h>
void main()
{
char str[] = "Letsfind\0course";
printf("%s", str);
}
A. Letsfindcourse
B. Letsfind
C. course
D. Compilation Error

15. Switch statement does not accept.


A. int
B. char
C. float
D. none of the above

16. Which loop is guaranteed to execute at least one time.


A. for
B. while
C. do while
D. None of the above

You might also like