WorksheetsCSE C Section
Total questions: 20
Worksheet time: 3mins
Who is the father of C language?
Steve Jobs
James Gosling
Dennis Ritchie
Rasmus Lerdorf
Which of the following is not a valid C variable name?
int number;
float rate;
int variable_count;
int $main;
All keywords in C are in
LowerCase letters
UpperCase letters
CamelCase letters
None of the mentioned
Which is valid C expression?
int my_num = 100,000;
int my_num = 100000;
int my num = 1000;
int $my_num = 10000;
What is short int in C programming?
The basic data type of C
Qualifier
Short is the qualifier and int is the basic data type
All of the mentioned
What is the result of logical or relational expression in C?
True or False
0 or 1
0 if an expression is false and any positive number if an expression is true
None of the mentioned
What is an example of iteration in C?
for
while
do-while
all of the mentioned
Functions can return enumeration constants in C?
true
false
depends on the compiler
depends on the standard
Functions in C Language are always
Internal
External
Both Internal and External
External and Internal are not valid terms for functions
scanf() is a predefined function in______header file.
stdlib. h
ctype. h
stdio. h
stdarg. h
Which program outputs "Hello World.." .?
main() { scanf("Hello World.."); }
main() { printf("Hello World.."); }
main() { print("Hello World.."); }
main() { scan("Hello World.."); }
What will be the output of the following C function?
#include <stdio.h>
enum birds {SPARROW, PEACOCK, PARROT};
enum animals {TIGER = 8, LION, RABBIT, ZEBRA};
int main()
{
enum birds m = TIGER;
int k;
k = m;
printf("%d\n", k);
return 0;
}
0
Compile time error
1
8
What will be the output of the following C code?
#include <stdio.h>
int const print()
{
printf("Sanfoundry.com");
return 0;
}
void main()
{
print();
}
Error because function name cannot be preceded by const
Sanfoundry.com is printed infinite times
Blank screen, no output
What will be the final value of x in the following C code?
#include <stdio.h>
void main()
{
int x = 5 * 9 / 3 + 9;
}
3.75
Depends on compiler
24
3
What will be the output of the following C code? (Initial values: x= 7, y = 8)
#include <stdio.h>
void main()
{
float x;
int y;
printf("enter two numbers \n");
scanf("%f %f", &x, &y);
printf("%f, %d", x, y);
}
7.000000, 7
Run time error
7.000000, junk
Varies
Comment on the following C statement.
n = 1;
printf("%d, %dn", 3*n, n++);
Output will be 3, 2
Output will be 3, 1
Output will be 6, 1
Output is compiler dependent
How many times i value is checked in the following C program?
#include <stdio.h>
int main()
{
int i = 0;
while (i < 3)
i++;
printf("In while loop\n");
}
2
3
4
1
Which of the following sequences are unaccepted in C language?
#if
#else
#endif
#if
#elif
#endif
#if
#if
#endif
#if
#undef
#endif
What will this program print?
main()
{
int i = 2;
{
int i = 4, j = 5;
printf("%d %d", i, j);
}
printf("%d %d", i, j);
}
4525
2525
4545
None of the these
What is the result after execution of the following code if a is 10, b is 5, and c is 10?
If ((a > b) && (a <= c))
a = a + 1;
else
c = c+1;
a = 10, c = 10
a = 11, c = 10
a = 10, c = 11
a = 11, c = 11
