Functions

Q1: 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

ANS:C - Error: return statement cannot be used with conditional operators

In a ternary operator, we cannot use the return statement. The ternary operator requires expressions but not code.



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.