NEW
Font size
WorksheetsUnit1-2nd Half
Total questions: 20
Worksheet time: 11mins
Choose a right C Statement
A) Loops or Repetition block executes a group of statements repeatedly.
B) Loop is usually executed as long as a condition is met.
C) Loops usually take advantage of Loop Counter
D) All the above.
Loops in C Language are implemented using.?
While Block
For Block
Do While Block
All the above
Choose correct C while loop syntax.
while(condition)
{
//statements
}
{
//statements
}while(condition)
while(condition);
{
//statements
}
while()
{
if(condition)
{
//statements
}
}
What is the output of C Program.?
int main()
{
while(true)
{
printf("RABBIT");
break;
}
return 0;
}
RABBIT
RABBIT is printed unlimited number of times.
No output
Compiler error.
What is the output of C Program.?
int main()
{
int a=5;
while(a==5)
{
printf("RABBIT");
break;
}
return 0;
}
RABBIT is printed unlimited number of times
RABBIT
Compiler error
None of the above.
What is the output of C Program.?
int main()
{
int a=25;
while(a <= 27)
{
printf("%d ", a);
a++;
}
return 0;
}
25 25 25
25 26 27
27 27 27
Compiler error
What is an Array in C language.?
A group of elements of same data type.
An array contains more than one element
Array elements are stored in memory in continuous or contiguous locations.
All the above.
An array Index starts with.?
-1
0
2
1
What is the output of C Program.?
int main()
{
int a[];
a[4] = {1,2,3,4};
printf("%d", a[0]);
}
Compiler error
1
2
4
What is the output of C Program.? int main() { char grade[] = {'A','B','C'}; printf("GRADE=%c, ", *grade); printf("GRADE=%d", grade); }
GRADE=some address of array, GRADE=A
GRADE=A, GRADE=some address of array
GRADE=A, GRADE=A
Compiler error
Choose correct statement about Functions in C Language.
A Function is a group of c statements which can be reused any number of times.
Every Function has a return type.
Every Function may no may not return a value.
All the above.
Choose a correct statement about C Function.?
main()
{
printf("Hello");
}
"main" is the name of default must and should Function.
main() is same as int main()
By default, return 0 is added as the last statement of a function without specific return type.
All the above
A function which calls itself is called a ___ function.
Self Function
Auto Function
Recursive Function
Static Function
What is the output of C Program with Functions.?
int main()
{
void show()
{
printf("HIDE");
}
show();
return 0;
}
No output
HIDE
Compiler error
None of the above
What is the output of C Program with functions.?
int main()
{
show();
printf("BANK ");
return 0;
}
void show()
{
printf("CURRENCY ");
}
CURRENCY BANK
BANK CURRENCY
BANK
Compiler error
What is a structure in C language.?
A structure is a collection of elements that can be of same data type.
A structure is a collection of elements that can be of different data type.
Elements of a structure are called members.
All the above
What is the output of C program with structures.?
int main()
{
structure hotel
{
int items;
char name[10];
}a;
strcpy(a.name, "TAJ");
a.items=10;
printf("%s", a.name);
return 0;
}
TAJ
Empty string
Compiler error
None of the above
What is the output of C program.?
int main()
{
struct book
{
int pages;
char name[10];
}a;
a.pages=10;
strcpy(a.name,"Cbasics");
printf("%s=%d", a.name,a.pages);
return 0;
}
empty string=10
C=basics
Cbasics=10
Compiler error
What is the need for a File when you can store anything in memory.?
Memory (RAM) is limited in any computer.
A file is stored on Hard Disk which can store Gigabytes of data
File stored on Hard Disk is safe even if PC is switched off. But Memory or RAM contents are cleared when PC is off.
All the above
Choose a correct statement about C file operation program.?
int main()
{
FILE *fp;
char ch;
fp=fopen("readme.txt","r");
while((ch=fgetc(fp)) != EOF)
{
printf("%c",ch);
}
}
FOPEN opens a file named readme.txt in Read Mode ("r).
EOF is End Of File. ch==EOF checks for end of file and while loop stops or exits.
FGETC(fp) is a function that returns one character and cursor goes to next character.
All the above
