C Programming and Problem Solving Questions and Answers 281 to 290

C Programming and Problem Solving

Questions 281 to 290


281.
Which of the following is not a keyword in C language?
(a)
Void
(b)
Volatile
(c)
Sizeof
(d)
Getchar
(e)
Short.
282.
With every use of a memory allocation function, what function should be used to release allocated memory, which is no longer needed?
(a)
unalloc()
(b)
dropmem()
(c)
dealloc()
(d)
release()
(e)
free() .
283.
Write the first line of the function definition for the following:
“a function called  add  accepts two integer arguments and returns a floating point value”
(a)
float add(int ,int)  
(b)
float add(int a,int b) 
(c)
float add()  
(d)
float  add( int a,b)
(e)
float add(a,b int).
284.
What is the output of the following program?
       #include<stdio.h>
       int c[10]=[1,2,3,4,5,6,7,8,9,10];  
       main()
       {   int a,b=0;
       for(a=0;a<10;++a)
       if(c[a]%2==1)  b+=c[a];
       printf(“%d”,b);
       }
(a)
20
(b)
24
(c)
25
(d)
30
(e)
35.
285.
Which of the following is not valid where p1, p2 are pointers?
(a)
p1+3 
(b)
p2-5 
(c)
* p1 + *  p2
(d)
p1+p2
(e)
p1-3.
286.
How much memory does the call malloc(10) allocate?
(a)
10 bytes
(b)
20 bytes
(c)
no memory allocation 
(d)
9 bytes
(e)
30 bytes
287.
How many union members can be initialized?
(a)
Only one member of a union at  one time
(b)
Any number of members of a union at one time
(c)
Union members can not be initialized
(d)
Only two members of a union at any one time
(e)
Only two members of a union at any time.
288.
Describe the following array
int  s[5][6]
(a)
s is a two –dimensional 30 element array(6 rows, 5 columns)
(b)
s is a two –dimensional 30 element array(5 rows, 6 columns)
(c)
s is a one –dimensional 30 element array(5 rows, 6 columns)
(d)
s is a two –dimensional 30 element array(5 rows, 5 columns)
(e)
s is a one dimensional 30 element array (6 rows, 5 columns).
289.
What is the output of the following statements?
for(i=10;i++;i<15)
printf(“%d”,i);
(a)
1011121314
(b)
101112131415
(c)
91011121314
(d)
101112131415
(e)
No output.
290.
What number would be shown on the screen after the following statements of C code are executed?
char ch;int i;ch= ‘g’;i=ch-‘a’;
printf(“%d”,i);
(a)
6
(b)
7
(c)
8
(d)
9
(e)
5.


Answers



281.
Answer : (d)
Reason:  Get char is not a key word in c language.
282.
Answer : (e)
Reason:  With every use of a memory allocation function, free() function should be used to release allocated memory, which is no longer needed.
283.
Answer : (b)
Reason:  Float add(int a, int b).
284.
Answer : (c)
Reason:  The out put of the program is 25.
285.
Answer : (c)
Reason:  *p1 + *p2 is not valid where p1,p2 are pointers.
286.
Answer : (a)
Reason:  10 bytes of memory will be allocated for the call malloc(10).
287.
Answer : (a)
Reason:  Only one member of a union at  one time can be initialized.
288.
Answer : (b)
Reason:  int s[5][6] means s is a two –dimensional 30 element array(5 rows,6 columns).
289.
Answer : (e)
Reason:  No output.
290.
Answer : (a)
Reason:  6  would be shown on the screen after the following statements of c are executed.



<< Prev 1...  2...  3...  4...  5...  6...  7...  8...  9...  10...  11... 12...  13...  14...  15...  16...  17...  18...  19...  20...  21...  22...  23...  24...  25...  26...  27...  28...  29...  30...  31...  32...  33...  34...  35...  36...  Next >>


No comments :

What you think about these Questions and Answers ? Let me know in comments.

Post a Comment