Functions

Q1: What will be the output of the program?
#include<stdio.h>
#include<stdlib.h>

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

A Infinite loop

B Prints "AptitudeCrack" 5 times

C Function main() doesn't calls itself

D Prints "AptitudeCrack"

ANS:D - Prints "AptitudeCrack"

Step 1: int i=0; The variable i is declared as in integer type and initialized to '0'(zero). Step 2: i++; Here variable i is increemented by 1. Hence i becomes '1'(one). Step 3: if(i<=5) becomes if(1 <=5). Hence the if condition is satisfied and it enter into if block statements. Step 4: printf("AptitudeCrack"); It prints "AptitudeCrack". Step 5: exit(1); This exit statement terminates the program execution. Hence the output is "AptitudeCrack".



img not found
img

For help Students Orientation
Mcqs Questions

One stop destination for examination, preparation, recruitment, and more. Specially designed online test to solve all your preparation worries. Go wherever you want to and practice whenever you want, using the online test platform.