The keyword used to transfer control from a function back to the calling function is

switch
goto
go back
return
What will be the output of the program in 16 bit platform (Turbo C under DOS)?
#include<stdio.h>

int main()
{
    int fun();
    int i;
    i = fun();
    printf("%d", i);
    return 0;
}
int fun()
{
    _AX = 1990;
}

Garbage value
0 (Zero)
1990
No output
Point out the error in the program

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

Missing parenthesis in return statement
The function should be defined as int f(int a, int b)
Redeclaration of a
None of above
Which of the following statements are correct about the program?
#include<stdio.h>

int main()
{
    printf("%p", main());
    return 0;
}

It prints garbage values infinitely
Runs infinitely without printing anything
Error: main() cannot be called inside printf()
No Error and print nothing
A function cannot be defined inside another function

True
False
Functions cannot return a floating point number

Yes
No
What is the notation for following functions?
1.  int f(int a, float b)
    {
        /* Some code */
    }

2.  int f(a, b)
    int a; float b;
    {
        /* Some code */
    }

1. KR Notation
2. ANSI Notation
1. Pre ANSI C Notation
2. KR Notation
1. ANSI Notation
2. KR Notation
1. ANSI Notation
2. Pre ANSI Notation
What will be the output of the program?
#include<stdio.h>
void fun(int*, int*);
int main()
{
    int i=5, j=2;
    fun(&i, &j);
    printf("%d, %d", i, j);
    return 0;
}
void fun(int *i, int *j)
{
    *i = *i**i;
    *j = *j**j;
}

5, 2
10, 4
2, 5
25, 4
Point out the error in the program
#include<stdio.h>

int main()
{
    int f(int);
    int b;
    b = f(20);
    printf("%d", b);
    return 0;
}
int f(int a)
{
    a > 20? return(10): return(20);
}

Error: Prototype declaration
No error
Error: return statement cannot be used with conditional operators
None of above
There is a error in the below program. Which statement will you add to remove it?
#include<stdio.h>

int main()
{
    int a;
    a = f(10, 3.14);
    printf("%d", a);
    return 0;
}
float f(int aa, float bb)
{
    return ((float)aa + bb);
}

Add prototype: float f(aa, bb)
Add prototype: float f(int, float)
Add prototype: float f(float, int)
Add prototype: float f(bb, aa)
Functions cannot return more than one value at a time

True
False
Every function must return a value

Yes
No
How many times the program will print "ASTIWZ" ?
#include<stdio.h>

int main()
{
    printf("ASTIWZ");
    main();
    return 0;
}

Infinite times
32767 times
65535 times
Till stack doesn't overflow
What will be the output of the program?
#include<stdio.h>
int i;
int fun();

int main()
{
    while(i)
    {
        fun();
        main();
    }
    printf("Hello");
    return 0;
}
int fun()
{
    printf("Hi");
}

Hello
Hi Hello
No output
Infinite loop
Point out the error in the program
#include<stdio.h>

int main()
{
    int a=10;
    void f();
    a = f();
    printf("%d", a);
    return 0;
}
void f()
{
    printf("Hi");
}

Error: Not allowed assignment
Error: Doesn't print anything
No error
None of above
Which of the following statements are correct about the function?
long fun(int num)
{
    int i;
    long f=1;
    for(i=1; i<=num; i++)
        f = f * i;
    return f;
}

The function calculates the value of 1 raised to power num.
The function calculates the square root of an integer
The function calculates the factorial value of an integer
None of above
If return type for a function is not specified, it defaults to int

True
False
If a function contains two return statements successively, the compiler will generate warnings. Yes/No ?

Yes
No
What will be the output of the program?
#include<stdio.h>
int reverse(int);

int main()
{
    int no=5;
    reverse(no);
    return 0;
}
int reverse(int no)
{
    if(no == 0)
        return 0;
    else
        printf("%d,", no);
    reverse (no--);
}

Print 5, 4, 3, 2, 1
Print 1, 2, 3, 4, 5
Print 5, 4, 3, 2, 1, 0
Infinite loop
In C all functions except main() can be called recursively.

True
False
Maximum number of arguments that a function can take is 12

Yes
No
What will be the output of the program?
#include<stdio.h>
void fun(int);
typedef int (*pf) (int, int);
int proc(pf, int, int);

int main()
{
    int a=3;
    fun(a);
    return 0;
}
void fun(int n)
{
    if(n > 0)
    {
        fun(--n);
        printf("%d,", n);
        fun(--n);
    }
}

0, 2, 1, 0
1, 1, 2, 0
0, 1, 0, 2
0, 1, 2, 0
Functions can be called either by value or reference

True
False
Will the following functions work?
int f1(int a, int b)
{
    return ( f2(20) );
}
int f2(int a)
{
    return (a*a);
}

Yes
No
What will be the output of the program?
#include<stdio.h>
int sumdig(int);
int main()
{
    int a, b;
    a = sumdig(123);
    b = sumdig(123);
    printf("%d, %d", a, b);
    return 0;
}
int sumdig(int n)
{
    int s, d;
    if(n!=0)
    {
        d = n%10;
        n = n/10;
        s = d+sumdig(n);
    }
    else
        return 0;
    return s;
}

4, 4
3, 3
6, 6
12, 12
A function may have any number of return statements each returning different values.

True
False
Usually recursion works slower than loops.

Yes
No
What will be the output of the program?
#include<stdio.h>

int main()
{
    void fun(char*);
    char a[100];
    a[0] = 'A'; a[1] = 'B';
    a[2] = 'C'; a[3] = 'D';
    fun(&a[0]);
    return 0;
}
void fun(char *a)
{
    a++;
    printf("%c", *a);
    a++;
    printf("%c", *a);
}

AB
BC
CD
No output
Names of functions in two different files linked together must be unique

True
False
Is it true that too many recursive calls may result into stack overflow?

Yes
No
What will be the output of the program?
#include<stdio.h>

int main()
{
    int fun(int);
    int i = fun(10);
    printf("%d", --i);
    return 0;
}
int fun(int i)
{
   return (i++);
}

9
10
11
8
In a function two return statements should never occur.

Yes
No
What will be the output of the program?
#include<stdio.h>
int check (int, int);

int main()
{
    int c;
    c = check(10, 20);
    printf("c=%d", c);
    return 0;
}
int check(int i, int j)
{
    int *p, *q;
    p=&i;
    q=&j;
    i>=45 ? return(*p): return(*q);
}

Print 10
Print 20
Print 1
Compile error
What will be the output of the program?
#include<stdio.h>
int fun(int, int);
typedef int (*pf) (int, int);
int proc(pf, int, int);

int main()
{
    printf("%d", proc(fun, 6, 6));
    return 0;
}
int fun(int a, int b)
{
   return (a==b);
}
int proc(pf p, int a, int b)
{
   return ((*p)(a, b));
}

6
1
0
-1
What will be the output of the program?
#include<stdio.h>

int main()
{
    int i=1;
    if(!i)
        printf("ASTIWZ,");
    else
    {
        i=0;
        printf("C-Program");
        main();
    }
    return 0;
}

prints "ASTIWZ, C-Program" infinitely
prints "C-Program" infinetly
prints "C-Program, ASTIWZ" infinitely
Error: main() should not inside else statement
What will be the output of the program?
#include<stdio.h>

int addmult(int ii, int jj)
{
    int kk, ll;
    kk = ii + jj;
    ll = ii * jj;
    return (kk, ll);
}

int main()
{
    int i=3, j=4, k, l;
    k = addmult(i, j);
    l = addmult(i, j);
    printf("%d %d", k, l);
    return 0;
}

12 12
No error, No output
Error: Compile error
None of above
What will be the output of the program?
#include<stdio.h>
int i;
int fun1(int);
int fun2(int);

int main()
{
    extern int j;
    int i=3;
    fun1(i);
    printf("%d,", i);
    fun2(i);
    printf("%d", i);
    return 0;
}
int fun1(int j)
{
    printf("%d,", ++j);
    return 0;
}
int fun2(int i)
{
    printf("%d,", ++i);
    return 0;
}
int j=1;

3, 4, 4, 3
4, 3, 4, 3
3, 3, 4, 4
3, 4, 3, 4
What will be the output of the program?
#include<stdio.h>
int func1(int);

int main()
{
    int k=35;
    k = func1(k=func1(k=func1(k)));
    printf("k=%d", k);
    return 0;
}
int func1(int k)
{
    k++;
    return k;
}

k=35
k=36
k=37
k=38
What will be the output of the program?
#include<stdio.h>

int main()
{
    int i=3, j=4, k, l;
    k = addmult(i, j);
    l = addmult(i, j);
    printf("%d, %d", k, l);
    return 0;
}
int addmult(int ii, int jj)
{
    int kk, ll;
    kk = ii + jj;
    ll = ii * jj;
    return (kk, ll);
}

12, 12
7, 7
7, 12
12, 7
What will be the output of the program?
#include<stdio.h>
int check(int);
int main()
{
    int i=45, c;
    c = check(i);
    printf("%d", c);
    return 0;
}
int check(int ch)
{
    if(ch >= 45)
        return 100;
    else
        return 10;
}

100
10
1
0
If int is 2 bytes wide.What will be the output of the program?
#include <stdio.h>
void fun(char**);

int main()
{
    char *argv[] = {"ab", "cd", "ef", "gh"};
    fun(argv);
    return 0;
}
void fun(char **p)
{
    char *t;
    t = (p+= sizeof(int))[-1];
    printf("%s", t);
}

ab
cd
ef
gh
What will be the output of the program?
#include<stdio.h>
int fun(int(*)());

int main()
{
    fun(main);
    printf("Hi");
    return 0;
}
int fun(int (*p)())
{
    printf("Hello ");
    return 0;
}

Infinite loop
Hi
Hello Hi
Error
What will be the output of the program?
#include<stdio.h>

fun(int i)
{
    i++;
    return i;
}

int main()
{
    int fun(int);
    int i=3;
    fun(i=fun(fun(i)));
    printf("%d", i);
    return 0;
}

5
4
Error
Garbage value
What will be the output of the program?
#include<stdio.h>
int fun(int);
int main()
{
    float k=3;
    fun(k=fun(fun(k)));
    printf("%f", k);
    return 0;
}
int fun(int i)
{
    i++;
    return i;
}

5.000000
3.000000
Garbage value
4.000000
What will be the output of the program?
#include<stdio.h>
#include<stdlib.h>

int main()
{
    int i=0;
    i++;
    if(i<=5)
    {
        printf("ASTIWZ");
        exit(1);
        main();
    }
    return 0;
}

Prints "ASTIWZ" 5 times
Function main() doesn't calls itself
Infinite loop
Prints "ASTIWZ"