NEW
Font size
WorksheetsQuiz - Functions in C
Total questions: 30
Worksheet time: 30mins
What is the output of this C code?
void foo();
void main()
{
void f();
f();
}
void foo()
{
printf("2 ");
}
void f()
{
printf("1 ");
foo();
}
What is the output of this C code? int main()
{
int x = 5;
int f();
x = f();
printf("%d", x);
}
int f()
{
int x=10;
return 15;
}
What will be the data type returned for the following function? int func()
{
return (double)(char)5.0;
}
What will be the output?
#include<stdio.h>
float circle(int);
void main()
{
float area = 0 ;
int radius = 1 ;
area = circle ( radius ) ;
printf ( "\n%f", area ) ;
}
float circle ( int r )
{
float a ;
a = 3.14 * r * r ;
return ( a ) ;
}
What will be the output?
#include<stdio.h>
int junk(int,int);
void main()
{
int i = 5, j = 2 ;
I = junk ( i, j ) ;
printf ( "\n%d %d", i, j ) ;
}
int junk ( int i, int j )
{
i *= i ;
j *= j ;
return i;
}
What is the scope of the variable z?
void myfunc()
{
int z;
z+= 7;
}
Find the error in the following code
#include <stdio.h>
#define PI 3.14;
int main()
{
printf("%f", PI);
return 10;
}
What is the output of this C code?
void main()
{
m();
}
void m()
{
printf("hi");
m();
}
What is the output of this C code?
void main()
{
static int x = 3;
x++;
if (x <= 5)
{
printf("hi");
main();
}
}
What will be the value of x in the following code?
char str1[]="YES", str2[]="yes";
int x = 0;
x= strcmp(str1, str2));
What will be the value of x in the following code?
char str1[]="yes", str2[]="yeb";
int x = 0;
x= strcmp(str1, str2));
What is the output of the following?
char a[]=”Hello”, char b[]=”BETA”;
strcpy(a, b);
printf("%s %s", a, b);
What is the output of the following?
char a[]=”Hello”,
char b[]=”BETA”;
strcat(a, b);
printf("%s %s", a, b);
What is the output of the following? char str1[]="Myworld";
char str2[]="wor";
char *x;
x = strstr(str1, str2);
printf("%s", x);
C language has many inbuilt functions. Which of the following is not a library function?
cos()
sqrt()
pow()
add()
