Professional Documents
Culture Documents
http://www.cquestions.com/2012/02/data-type-questions-in-c.html
http://www.indiabix.com/c-programming/pointers/
Directions
Step 1 : Identify solution without any assistance (compiler, text book, Google, etc).
Step 2 : Research (text book, Google), work (compiler), and implement the solution.
Resolve the difference by collaborating and corroborating with your class mates. If still not resolved, check with me.
Due to compilers using different standards and some not conforming to standards, it is possible for the output to be different or
incorrect. So it’s important that you identify the correct version and use that as reference for the exam preparation.
Some questions might refer to topics we have not covered yet for the current exam. Save it for the future exam.
If the code generates a compilation error, then identify the reason for the error and fix it.
void main(void)
{
int fun(int);
int i = fun(10);
printf("%d\n", --i);
}
int fun(int i)
{
return (i++);
}
3 What is the outcome/output of the following C program, if any? 3314
#include<stdio.h>
int i; Answer
int fun1(int); 4343
int fun2(int); Explanation
Program wants to do fun1 first
void main(void) and then fun2
{ Program calls to fun1 executes
int i=3; then continue first but pulls
fun1(i); variable assignment out first.
printf("%d,", i); Void main only uses the
fun2(i); variable inside void main
printf("%d", i); regardless if incremented
} outside.
int fun1(int j)
{
printf("%d,", ++j);
return 0;
}
int fun2(int i)
{
printf("%d,", ++i);
return 0;
}
4 int addmult(int ii, int jj) Return(kk, ll);
{ “,” discards first variable,
int kk, ll; keeps second
kk = ii + jj;
ll = ii * jj; Answer 12 12
return (kk, ll);
}
void main(void)
{
int i=3, j=4, k, l;
k = addmult(i, j);
l = addmult(i, j);
printf("%d, %d\n", k, l);
}
5 A function cannot be defined inside another function TRUE
A. True Function can be called in
B. False another function
6 Functions cannot return values of more than one variable at a time true
A. True
B. False
7 If return type for a function is not specified, it defaults to int t
A. True
B. False
8 Functions can be called either by value or reference t
A. True
B. False
9 A function may have any number of return statements, each returning it’s T
independent values. https://www.indiabix.com/c-
A. True programming/functions/029002
B. False #6
10 Every function must return a value No #2
A. Yes https://www.indiabix.com/c-
B. No programming/functions/030001
11 Functions cannot return a floating point number Yes #2
A. Yes https://www.indiabix.com/c-
B. No programming/functions/030001
A. x is 15 x=add(x);” was
B. x is 5 added before
C. Compile error : variable y not used “printf(“x is
None of the above %d\n”,x);” this
assigns the
function output
to the local
operator X
18 What is the expected behavior of the following code?
#include<stdio.h> 5 10
int swap(int x, int y);
Dont have to declare
int main(void) LOCAL VARIABLE HAS
{
int x=5, y =10; PRECEDENCE OVER GLOBAL
swap(x,y);
printf("X is %d Y is %d\n",x,y);
}