Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
13 views

What will be the output of the following C code

Find the output of the following C code

Uploaded by

Anithadevi N
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views

What will be the output of the following C code

Find the output of the following C code

Uploaded by

Anithadevi N
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Bringal

What will be the output of the following C code?

1. #include <stdio.h>
2. void main()
3. {
4. m();
5. }
6. void m()
7. {
8. printf("hi");
9. m();
10. }

a) Compile time error


b) hi
c) Infinite hi
d) Nothing
View Answer
Answer: c
Explanation: None.

Point out the error in the program


#include<stdio.h>
int f(int a)
{
a > 20? return(10): return(20);
}
int main()
{
int f(int);
int b;
b = f(20);
printf("%d\n", b);
return 0;
}
A. Error: Prototype declaration

B. No error

C. Error: return statement cannot be used with conditional operators

D. None of above
Answer: Option C

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\n", a);
return 0;
}
float f(int aa, float bb)
{
return ((float)aa + bb);
}

A
Add prototype: float f(aa, bb)
.

B
Add prototype: float f(int, float)
.

C
Add prototype: float f(float, int)
.

D
Add prototype: float f(bb, aa)
.
Answer: Option B
Explanation:
The correct form of function f prototype is float f(int, float);

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;
}

A The function calculates the value of 1 raised to power num.


.

B
The function calculates the square root of an integer
.

C
The function calculates the factorial value of an integer
.

D
None of above
.
Answer: Option C
Explanation:
Yes, this function calculates and return the factorial value of an given integer num.

#include<stdio.h>
int f(int a)
{
a > 20? return(10): return(20);
}
int main()
{
int f(int);
int b;
b = f(20);
printf("%d\n", b);
return 0;
}

Which of the following is a complete function?


A. int funct();
B. int funct(int x) {return x=x+1;}
C. void funct(int) { printf( "Hello");
D. void funct(x) { printf( "Hello"); }

You might also like