C Programming and Problem Solving
Questions 311 to 320
Which of the following function is used to copy one string
to another string?
(a) strcopy (b) strcp (c) strcpy (d) stringcopy (e)
srtcp.
|
|
Which of the following is a not a keyword in C language?
(a) void (b) volatile (c) sizeof (d) getchar (e) short.
|
|
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;}.
|
|
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).
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
----------operator is used to access structure members
(a) & (b) * (c) . (d) + (e) -.
|
|
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
Answer : (b)
Reason : strcp is the
correct function to copy one string to another string
|
|
Answer : (d)
Reason : Remaining
all are keywords of c except getchar
|
|
Answer : (b)
Reason : firstly
variable is initialized ,Condition is checked, stmts are executed and
incrementation takes place and condition is check
|
|
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,..)
|
|
Answer : (c)
Reason : Firstly 1 is
stored in b and then 3 is addedto it 4,4+5,9+7,16+9=25.
|
|
Answer : (c)
Reason : addresses of
the memory cant be added.
|
|
Answer : (a)
Reason : malloc
function defines how many memory bytes to be allocated.so result is 10 bytes
|
|
Answer : (b)
Reason : Remaining
choices are contradictory to above declaration.
|
|
Answer : (c)
Reason : the
remaining are address operator,multiplication,addition,subtraction operator
|
|
Answer : (a)
Reason : Remaining is
contradictory to the definition of union
|
No comments :
Post a Comment