Computer Sciences > Gate 2017 Set-1 > C Programming
Consider the C functions foo and bar given below:

int foo(int val)
{
    int x = 0;
    while (val > 0)
    {
        x = x + foo(val--);
    }
    return val;
}
int bar(int val)
{
    int x = 0;
    while (val > 0)
    {
        x = x + bar(val-1);
        return val;
}
}


Invocations of foo(3) and bar(3) will result in:
A
Return of 6 and 6 respectively.
B
Infinite loop and abnormal termination respectively.
C
Abnomal termination and infinite loop respectively.
D
Both terminating abnormally.

Correct : C Programming

Similar Questions

What is printed by the following ANSI C program? #include<stdio.h> int main(int argc, char *argv[]) {     int a[3][3][3] =     {{...
#311 MCQ
What is printed by the following ANSI C program? #include<stdio.h> int main(int argc, char *argv[]) {     int a[3][3][3] =     {{...
#311 MCQ
What is printed by the following ANSI C program? #include<stdio.h> int main(int argc, char *argv[]) {     int a[3][3][3] =     {{...
#311 MCQ

Related Topics

No tags found

Unique Visitor Count

Total Unique Visitors

Loading......