#include<stdio.h> #include<stdlib.h> int main() { int i=0; i++; if(i<=5) { printf("CuriousTab"); exit(1); main(); } return 0; }
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("CuriousTab"); It prints "CuriousTab".
Step 5: exit(1); This exit statement terminates the program execution.
Hence the output is "CuriousTab".
Example:
Call by value means c = sub(a, b); here value of a and b are passed.
Call by reference means c = sub(&a, &b); here address of a and b are passed.
Example:
#include<stdio.h>
int mul(int, int); /* Function prototype */
int main()
{
int a = 4, b = 3, c;
c = mul(a, b);
printf("c = %d\n", c);
return 0;
}
int mul(int a, int b)
{
return (a * b);
return (a - b); /* Warning: Unreachable code */
}
Output:
c = 12
Example:
#include <stdio.h>
float sub(float, float); /* Function prototype */
int main()
{
float a = 4.5, b = 3.2, c;
c = sub(a, b);
printf("c = %f\n", c);
return 0;
}
float sub(float a, float b)
{
return (a - b);
}
Output:
c = 1.300000
Copyright ©CuriousTab. All rights reserved.