C Programming and Problem Solving Questions and Answers 311 to 320

C Programming and Problem Solving

Questions 311 to 320



311.
Which of the following function is used to copy one string to another string?
(a)  strcopy             (b)  strcp                 (c)  strcpy               (d)  stringcopy         (e)  srtcp.
312.
Which of the following is a not a keyword in C language?
(a)  void                 (b)  volatile              (c)  sizeof                (d)  getchar             (e)  short.
313.
Which of the following is equivalent to for (expr1;expr2;expr3)
(a)   while(expr1){ expr2; statement; expr3;}
(b)   expr1; while(expr2){statement; expr3;}
(c)   while(expr2) {expr1; statement; expr3;}
(d)   expr2; while(expr3){expr2; statement; expr1;}
(e)   while(expr3) {expr1; statement; expr2;}.
314.
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).
315.
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.
316.
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.
317.
How much memory does the call malloc(10) allocate
(a)  10 bytes                                         (b)  20 bytes            (c)  no memory allocation   
(d)  9 bytes                                            (e)  100 bytes.
318.
Explain the following 
int (*pf)( char *a,char * b)
(a)   pf is function that accepts two characters as arguments and returns an integer
(b)   pf is a pointer to a  function that accepts two pointers to characters as arguments and returns an integer.
(c)   pf is pointer to a function that accepts two characters as arguments and returns an integer.
(d)   pf is a data type that accepts two integers as arguments and returns an integer
(e)   not valid statement.
319.
----------operator is used to access structure members
(a)  &                      (b)  *                       (c)  .                        (d)  +                      (e)  -.
320.
How many union members can be initialized.
(a)   Only one member of a union at any 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.



Answers



311.
Answer : (b)
Reason : strcp is the correct function to copy one string to another string
312.
Answer : (d)
Reason : Remaining all are keywords of c except getchar
313.
Answer : (b)
Reason : firstly variable is initialized ,Condition is checked, stmts are executed and incrementation takes place and condition is check
314.
Answer : (b)
Reason : The syntax for function prototype is float functionname(int,int )and infunction declaration arguments are passed whose syntax returntype functionname(datatype argument1,datatype agr2,..)
315.
Answer : (c)
Reason : Firstly 1 is stored in b and then 3 is addedto it 4,4+5,9+7,16+9=25.
316.
Answer : (c)
Reason : addresses of the memory  cant be added.
317.
Answer : (a)
Reason : malloc function defines how many memory bytes to be allocated.so result is 10 bytes
318.
Answer : (b)
Reason : Remaining choices are contradictory to above declaration.
319.
Answer : (c)
Reason : the remaining are address operator,multiplication,addition,subtraction operator
320.
Answer : (a)
Reason : Remaining is contradictory to the definition of union



<< 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