Question 11
double foo (double); /* Line 1 */
int main()
{
double da, db;
// input da
db = foo(da);
}
double foo(double a)
{
return a;
}
Question 12
Consider the following C function
void swap (int a, int b)
{
int temp;
temp = a;
a = b;
b = temp;
}
In order to exchange the values of two variables x and y.
Question 13
int incr(int i)
{
static int count = 0;
count = count + i;
return (count);
}
main()
{
int i,j;
for (i = 0; i <=4; i++)
j = incr(i);
}
Question 14
void f1 (int a, int b)
{
int c;
c=a; a=b; b=c;
}
void f2 (int *a, int *b)
{
int c;
c=*a; *a=*b;*b=c;
}
int main()
{
int a=4, b=5, c=6;
f1(a, b);
f2(&b, &c);
printf (“%d”, c-a-b);
return 0;
}
Question 15
#include \"stdio.h\"
int main()
{
int a = 10;
int b = 15;
printf(\"=%d\",(a+1),(b=a+2));
printf(\" %d=\",b);
return 0;
}
Question 16
#include \"stdio.h\"
int main()
{
int a = 10;
printf(\"=%d %d=\",(a+1));
return 0;
}
Question 17
/* First Declaration */
int (*funPtr1)(int), (*funPtr2)(int);
/* Second Declaration*/
typedef int (*funPtr)(int);
funPtr funPtr1, funPtr2;
Question 18
#include \"stdio.h\"
int foo(int a)
{
printf(\"%d\",a);
return 0;
}
int main()
{
foo;
return 0;
}
Question 19
#include <stdio.h>
int funcf (int x);
int funcg (int y);
main()
{
int x = 5, y = 10, count;
for (count = 1; count <= 2; ++count)
{
y += funcf(x) + funcg(x);
printf (\"%d \", y);
}
}
funcf(int x)
{
int y;
y = funcg(x);
return (y);
}
funcg(int x)
{
static int y = 10;
y += 1;
return (y+x);
}
Question 20
#include<stdio.h>
int f(int n, int k)
{
if (n == 0)
return 0;
else if (n % 2)
return f(n/2, 2*k) + k;
else return f(n/2, 2*k) - k;
}
int main ()
{
printf(\"%d\", f(20, 1));
return 0;
}
There are 41 questions to complete.