C Objective type Questions part -1

Objective type questions


1. The index or subscript value for an array of size ‘n’ ranges from
(a) 1 to n-1
(b) 0 to n-1
(c) 1 to n
(d) 0 to n
2. If we don’t initialize a static array, what will be the elements set to:
(a) 0
(b) a floating point number
(c) an undetermined value
(d) character constant
3. A string is an array of
(a) integers
(b) floating point numbers
(c) characters
(d) boolen values
4. int cal sum(int a, int b);
In the above, int at the beginning indicates
(a) name of function
(b) both function arguments are integer
(c) return type of function
(d) received type of function
5. When a function is recursively called, all automatic variables are
(a) stored in a stack
(b) stored in a list
(c) stored in queue
(d) stored in an array
6. What is wrong with the following program
main()
{
 char m1[9]= “message1”;
char m2[9]=“message2”;
m2=m1;
printf(“msg is %s”,m2);
 }
(a) array cannot be initialized as above
(b) array is not a left value and so cannot be assigned to
(c) char array cannot be printed directly using printf
(d) program compiles without error, but prints an unpredictable value
7. Which of the following is not a storage class?
(a) external
(b) automatic
(c) register
(d) define
8. The array is declared as float a[5]; and the memory address of a[0] is 4056. What is the memory address of a[3].
(a) 4056
(b) 4056
(c) 4059
(d) 4068
9. Two dimensional array elements are stored
(a) system dependent
(b) in row major order
(c) complier dependent
(d) in column major order
10. How many values a function can return at a time
(a) only one
(b) depends on the system
(c) infinite values
(d) 2
11. When compared to call by value, the call by reference is in execution
(a) equal
(b) fast
(c) slow
(d) neither slow nor fast
12. Which of the following statement is wrong with respect to a storage class
(a) it specifies the defualt initial value
(b) it specifies the life of a variable
(c) by defualt a storage class is static
(d) if specifies where variable is stored
13. Array elements are stored in
(a) Sequential memory locations
(b) Scattered memory locations
(c) Direct memory locations
(d) Random memory location
14. The number of elements in array declaration
(a) does not require to be specified
(b) dynamically identifies based on largest index used in program
(c) assume default size as ‘0’
(d) requires to be specified
15. The following program
main( )
{
static int a[ ] = { 7, 8, 9 };
printf(“%d”, a[2] = 2[a] + a[2]);
}
(a) results in segmentation violation error
(b) runtime error
(c) will compile successfully
(d) result is buss error
16. Find the output of the following program
main()
{ char name1 [4] = {‘R’, ‘A’, ‘V’, ‘I’};
char name2 [5] = {‘R’,‘A’,‘V’,‘I’};
printf (“%s”, name1);
printf (“%s”, name 2);
}
(a) RAVI RAVI
(b) Garbage value
RAVI
(c) RAVI
garbage value
(d) RAVI garbage value
RAVI
17. The purpose of return statement is
(a) To return control back to the calling function
(b) To return control and value to calling function
(c) To return void
(d) To return value to the calling function
18. Which of the following statements is correct when an array is passed to a called function
(a) function-name ( array-name [ ] )
(b) function-name ( array-name , size )
(c) not possible
(d) function-name ( array-name[size])
19. The storage area for register variables
(a) cache
(b) memory
(c) processor registers
(d) virtual memory
20. What is the control string for representing string
(a) %c
(b) %s
(c) %f
(d) %d
21. How many values a function can return at a time
(a) only one
(b) infinite values
(c) depends on the system
(d) 2
22. What is the output of the following program
void main()
{
int x = 2;
sqr(x);
printf(“%d”, x);
}
sqr(x)
{
int y;
y = x * x;
printf (“%d”, y);
}
(a) 4 2
(b) 2 2
(c) 2 4
(d) 4 4
23. Every executable C program must contain a
(a) printf function
(b) scanf, printf and main functions
(c) main function
(d) scanf function
24. Give the output of the following program:
#include < stdio.h >
main()
{
int I=1;
while (I < 5)
{
printf(“%d”, I);
}
} /* End of Main */
(a) Warning for no return type for main ( )
(b) Print the value of I as 1
(c) Infinite loop
(d) Prints the value of I as11111
25. Array is used to represent the following
(a) A list of data items of different data type
(b) A list of data items of real data type
(c) A list of data items of same data type
(d) A list of data items of integer data type
26. Dynamic memory allocation in array results in
(a) allocation of memory at compile time
(b) allocation of memory at file saving time
(c) allocation of memory at runtime
(d) allocation of memory at debugging time
27. Arrays are passed as arguments to a function by
(a) reference
(b) both value and reference
(c) context
(d) value
28. What is the output of the following program
# includes <stdio.h>
# include <conio.h>
void main()
{
int a1[5] ={1};
int b = 0, k = 0;
for (b=0; b<=4; b++)
printf (“%d” , ++ a1[0]);
}
(a) 11111
(b) 23456
(c) 12345
(d) 12222
29. The statement used to send back any value to the calling function is
(a) exit
(b) return
(c) break
(d) continue
30. What is the output of
main()
{
int x, change (int);
x = 20;
change (x);
printf (“%d”, x);
return 0;
}
change (int x);
{
x = 10;
printf (“%d”. x);
}
(a) 10 30
(b) 10 20
(c) 10 10
(d) 20 20
31. A static variable is one
(a) which cant be initialized
(b) which is same as an automatic variable but it is placed at the head of the program
(c) which is initialized once and cant be changed at run time
(d) which retains its value through out the life of the program
32. main()
{
printf(“welcome to c programming\n”);
main();
}
output of the program code
(a) Infinite loop
(b) Runtime error
(c) welcome to c programming
(d) compile time error
33. What will be the output of the following program?
void main()
{
char x[ ] = {‘s’, ‘a’, NULL };
printf (“\n %d”, sizeof (x));
}
(a) 2
(b) 3
(c) 0
(d) 1
34. The variables which are declared outside the program are called
(a) global variables
(b) formal variables
(c) local variables
(d) register variable
35. The constant ‘\00 is called as
(a) full
(b) null
(c) zero
(d) nill
36. What kind of variable is suitable to count how many times a function is called
(a) register
(b) external
(c) auto
(d) static
37. An array can have dimension(s).
(a) single
(b) multiple
(c) three
(d) double
38. main() is
(a) user defined function
(b) friendly function
(c) library function
(d) member function
39. Which function returns single character
(a) printf
(b) putchar
(c) scanf
(d) getchar
40. Which of the following is a primary data type?
(a) int
(b) enum
(c) array
(d) typedef
41. What is the difference between the 5’s in the below expressions.
int num[5];
num[5]=10;
(a) Both specify array size
(b) First is array size, second is particular element
(c) First is particular element , second is array size
(d) First is particular element , second is type
42. The amount of storage required for holding elements of the array depends on
(a) run-time requirement
(b) data type
(c) size
(d) data type and size


Followers