Você está na página 1de 5

Worksheet5

1. In the following code in which order the functions would be called?


a = f1(23, 14) * f2(12/4) + f3();
2. In the following code in which order the functions would be called?
a = (f1(23, 14) * f2(12/4)) + f3();
3. What would be the output of the following program?
#include <stdio.h>
#include <math.h>
main()
{
printf("%f", sqrt(36.0));
}

4. Would the following printf()s print the same values for any value of a?
<Yes/No>
#include <stdio.h>
main()
{
float a;
scanf ("%f", &a);
printf("%f", a+a+a);
printf("%f", 3*a);
}

5. What error would the following function give on compilation?


f(int a, int b)
{
int a;
a = 20;
return a;
}

6. What would be the output of the following program?


#include <stdio.h>
main()
{
int a,b;
a = sumdig(123);
b = sumdig(123);
printf("%d %d", a,b);
}
sumdig(int n)
{
static int s = 0;
int d;
if (n!= 0)
{
d = n%10;
n = (n-d)/10;
s = s+d;
sumdig(n);
}
else
return (s);
}

7. There is a mistake in the following code. Add a statement in it to remove it.


#include <stdio.h>
main()
{
int a
a = f(10, 3.14);
printf("%d", a);
}
f(int aa, float bb)
{
return ((float) aa + bb);
}

8. Point out the error in the following code.


#include <stdio.h>
main()
{
int a = 10;
void f();
a = f();
printf("\n%d", a);
}
void f()
{
printf("\n Hi");
}

9. What are the following two notations of defining functions commonly known
as:
int f(int a, float b)
{
/* some code */
}
int f(a, b)
int a; float b;
{
/* some code */
}

10. Is it true that too many recursive calls may result into stack overflow?
<Yes/No>

11. How many times the following program would print Jamboree?
#include <stdio.h>
main()

{
printf("\n Jamboree");
main();
}

12. Point out the error, if any, in the following function.


#include <stdio.h>
main()
{
int b;
b = f(20);
printf("%d", b);
}
int f (int a)
{
a > 20 ? return(10) : return(20);
}
13. Will the following functions work? <Yes/No>
f1 (int a, int b)
{
return (f2(20));
}
f2(int a)
{
return (a*a);
}

14. What would be the output of the following program?


#include <stdio.h>
main()
{
printf(5 + "Fascimile");
}

15. What would be the output of the following program?


#include <stdio.h>
main()
{
printf("%c", "abcdefgh"[4]);
}