NEW
Font size
Worksheets'C'Programming Basics - Prepared by Feroz Khan A.B
Total questions: 15
Worksheet time: 21mins
#include<stdio.h>
main()
{
int x = 1;
do
printf("%d ", x);
while(x++<=1);
}
1
Error
1 2
No output
Compiler generates ___ file.
Executable code
Object code
Assembly code
All of the above
What is the built in library function to compare two strings?
string_cmp()
strcmp()
equals()
str_compi()
Which of the following is not a valid variable name declaration?
int __a3;
int __3a;
int a_3;
None of the aove
#include<stdio.h>
int main()
{
static int var = 5;
printf("%d ",var--);
if(var)
main();
}
5 4 3 2 1
5 5 5 5 5
0 0 0 0 0
5
#include<stdio.h>
int main()
{
static int i=5;
if(--i){
main();
printf("%d ",i);
}
}
5 5 5 5 5
5 4 3 2 1
0 0 0 0 0
Error
#include<stdio.h>
int main()
{
int x;
printf("%d",scanf("%d",&x));
/* Suppose that input value given
for above scanf is 20 */
return 1;
}
20
Error
1
0
# include <stdio.h>
int main()
{
int i=0;
for(i=0; i<20; i++)
{
switch(i)
{
case 0:
i+=5;
case 1:
i+=2;
case 5:
i+=5;
default:
i+=4;
break;
}
printf("%d ", i);
}
getchar();
return 0;
}
21
16
16 21
None
All keywords in C are in ____________
LowerCase letters
UpperCase letters
CamelCase letters
All of the above
What is required in each C program?
The program must have at least one function.
The program does not require any function.
Input data
Output data
main() { int i = 2;
{ int i = 4, j = 5;
printf("%d %d", i, j);
}
printf("%d %d", i, j);
}
4525
2525
4545
Error
What is the output of this statement "printf("%d", (a++))"?
The value of (a + 0)
The current value of a
0
Garbage
How many times will the following loop execute?
for(j = 1; j <= 10; j = j-1)
Forever
Never
0
1
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
Which one of the following is a loop construct that will always be executed once?
for
while
if
do while
