Professional Documents
Culture Documents
Ans: b Ans: b
Q12. Which of the following statements declares a function
Q4. What will be the output of the program if the array begins at with a pointer variable as a parameter?
65472 and each integer occupies 2 bytes?
void main( ) a) void fun (int ptr);
{ b) void fun (int& ptr);
int a[3][4]={1,2,3,4,4,3,2,1,7,8,9,0}; c) void fun (*int ptr);
printf("%u %u", a+1, &a+1); d) void fun (int* ptr);
} Ans: d
a) 65474, 65488 c) 65480, 65496 Q13. Array passed as an argument to a function is interpreted as:
b) 65480, 65488 d) 65474, 65476
Ans: c a) Sizeof the array
b) Values of the first elements of the array
Q5. What is the index number of the last element of an array with 29 c) Address of the first element of the array
elements? d) Number of the elements in the array
a) 29 c) 27
b) 28 d) Programmer-defined Ans: c
Ans: b Q14. Which of the following statements about pointer constants is
true?
Q6. Which of the following gives the memory address of the first a) The value in a pointer constant can change from run to run.
element in array foo, an array with 100 elements? b) The type of a pointer constant is address.
a) foo[0]; c) &foo; c) The asterisk operator (*) extracts the address for a variable.
b) foo[1]; d) foo; d) Pointer constants cannot be saved.
Ans: a
Ans: c
Q15. Which of the following statements about two-dimensional arrays b) 30 d) Compilation Error
is false?
Ans: c
a) The size of the first dimension is optional.
b) Two-dimensional arrays must be unitialized or fully initialized.
Q20. Which of the operations are valid on pointers?
c) By convention the first dimension specifies the number of rows.
d) Accessing individual values requires two indexes.
a) Comparison c) Addition of two pointers
b) Division d) Modulus
Ans: b
Ans: a
Q16. Which of the following storage classes have a local scope?
a) static Q21. Have a look at the following piece of code and state the output.
b) extern
c) function void main()
d) array {
char str[20]="AB\0CDE";
Ans: a int i;
Q17. Have a look at the following piece of code and state the output.
for(i=0;str[i]!='E'&&str[i]!='\0';i++)
printf("%c",str[i]);
int a; getch();
int main() }
{ a) Prints ABCD on the screen.
int *ptr=&a; b) Prints ABCDE on the screen.
printf("\n%d",*&*(ptr)); c) Prints AB on the screen.
getch(); d) Results in a compiler error.
} Ans: c
a) Prints a garbage value on the screen.
Q22. Let x be an array, which of the following statements are
b) Prints 0 on the screen.
illegal:
c) Prints the address of variable a on the screen.
I. ++x
d) Results in a compiler error.
II. x+1
III. x++
Ans: b IV. x*2
Q18. Have a look at the following piece of code and state the output. a) I and II c) II and III
b) I, II and III d) I, III and IV
void fun(double *);
void main() Ans: d
{
double f=24.44,*ptr=&f; Q23. Which of the following storage class variables automatically
fun(ptr); get initialized to 0.
printf("\n%f",*ptr); a) static c) register
getch(); b) auto d) array
}
void fun(double *ptr) Ans: a
{
++ptr; Q24. Have a look at the following piece of code and state the
} output.
Q13. What will be the output of the program? a) printf("\n"); b) echo "\\n";
#include<stdio.h> c) printf('\n'); d) printf("\\n");
void main( )
{ Ans: d
int a[5]={5,1,15,20,25};
Q21. The ____ operator is used to extract the address for a variable.
int i,j,m;
i=++a[1]; a) address (&)
j=a[1]++; b) pointer (^)
m=a[i++]; c) indirection (*)
printf("%d, %d, %d", i,j,m); d) selection (>)
}
Ans: a
a) 2, 3, 20 b) 2, 1, 15
Q22. Which of the following statements declares a function
with a pointer variable as a parameter?
c) 3, 2, 15 d) 1, 2, 5
a) void fun (int * ptr);
Ans: c b) void fun (int& ptr);
c) void fun (*int ptr);
Q14. What will be the output of the program if the array begins at d) void fun (int ptr);
65472 and each integer occupies 2 bytes?
void main( ) Ans: a
{
int a[3][4]={1,2,3,4,4,3,2,1,7,8,9,0}; Q23. Array passed as an argument to a function is interpreted as:
printf("%u %u", a+1, &a+1);
a) Sizeof the array
}
b) Address of the first element of the array
c) 65474, 65488 b) 65480, 65496
c) Value of the first element of the array
c) 65480, 65488 d) 65474, 65476
d) Number of the elements in the array
Ans: b Ans: b
Q15. What is the index number of the last element of an array with 27 Q24. Which of the following statements about pointer constants is
elements? true?
a) 27 b) 28 a) The type of a pointer constant is address.
c) 26 d) Programmer-defined b) The asterisk operator (*) extracts the address for a variable.
c) The value in a pointer constant can change from run to run.
Ans: c d) Pointer constants cannot be saved.
Q16. Which of the following gives the memory address of the first Ans:c
element in array foo, an array with 100 elements?
a) foo[0]; b) &foo; Q25. The function which can be used to change the case of a string is
c) foo[1]; d) foo;
a) strcase
b) strlwr
Ans: b c) strrev
d) strcmp
Q17. Which of the following function is more appropriate for reading
in a multi-word string? Ans: b