WorksheetsC Programming and Flowchart Basics – Worksheet Extraction
Total questions: 150
Worksheet time: 2hrs 31mins
_______ is the symbol typically used in a flowchart to represent a decision point.
Rectangle
Diamond
Oval
Circle
The first step in solving a programming problem is:
Coding
Testing
Algorithm
Debugging
A flowchart mainly represents:
Program syntax
Logical flow of execution
Machine instructions
Compiler rules
______________ is the symbol typically used in a flowchart to represent the end of the program.
Oval
Diamond
Rectangle
Circle
Pseudo-code is written using:
Binary language
Programming syntax
English-like statements
Machine code
The main purpose of writing an algorithm before coding in C
To minimize the size of the program
To improve the speed of execution
To make coding easier by clearly defining the logic
To avoid using any loops in the program
The data type used to store integer values is:
float
char
int
double
The size of the char data type is:
2 bytes
4 bytes
1 byte
8 bytes
A constant value in C remains:
Modifiable
Fixed during execution
Input dependent
Compiler dependent
A valid variable name in C is __________
float
1stnumber
score#
_score
A valid C variable name is:
total-marks
1value
total_marks
float
The lifetime of a global variable lasts _______________.
Throughout the program's execution.
Until redefined in another function.
Until the function ends.
For a single loop iteration.
The function used for output is:
scanf()
printf()
input()
output()
The symbol %d is used for:
float
character
integer
string
The operator + belongs to:
Logical
Relational
Arithmetic
Conditional
The correct symbol for the modulus operator in C is ______.
/
%
||
!=
A global variable is _______________.
A variable declared outside all functions
A constant declared with '#define'
A variable that has a local scope
A variable declared inside a function
In C, the `goto` statement ____________.
Stops the program
Iterates through loops
Jumps to a labeled statement
Moves to the next function
A loop that checks the condition at the end of the loop block is ______________.
do-while
if-else
for
while
In a nested `if` statement, the condition that will be executed depends on ______________.
The value of a global variable
Both outer and inner conditions
The deepest nested condition
The first condition only
In C, a switch-case statement __________________.
Can handle floating-point comparisons.
Executes a block of code for a specific value.
Ends with a `continue` statement.
Evaluates a condition.
The result of the expression 10/3 in C, when both operands are integers, is __________.
4
3.33
3
3.0
The precedence of arithmetic operators is (from highest to lowest):
+, -, %, *, /
%, *, /, +, −
%, +, /, *, -
%, +, -, *, /
Identify the logical operator in C.
==
=-
+=
&&
Output of the following
#include
Both are true
At least one is false
Compilation error
Logical error
Compute the output for the following code:
#include
b is positive
a is greater than b
b is non-positive
Identify the correct assignment:
100=a=b=c;
a=100=b=c;
a=b=c=100;
a=b=100=c;
Char type uses ________ bytes.
1
2
3
4
For which type is the format specifier "%i" used?
char
float
int
number
The difference between float and double in C
Both are used for the same purpose.
Double is more precise than float and can store 64 bits.
Double can store just double values compared to float values.
Double is an enhanced version of float and was introduced in C#.
__________ is not an arithmetic expression in C
x != 10
x %= 10
x /= 10
x = 10
Compute the output of the following snippet:
#include
2
2.5
error
warning
_______ format specifier is used to read and print a string using printf() and scanf() in C.
%str
%s
%c
%p
Identify the valid syntax for creating a while loop.
while { } (condition)
while { }
while(condition) { }
condition { while() }
Give the output of the following C code.
#include
11 12 13 14 15 16 17 18 19 20
11 13 15 17 19 21
11 13 15 17 19
12 14 16 18 20
Which of these statements is correct in the case of a while loop in C?
Executes the block until the condition becomes false.
Is an exit-controlled loop.
There might be a condition when the loop will execute at least once.
The loop will increment only by +1.
______________ if the loop condition never becomes false.
Loop will not run
Program will loop infinitely
Program will throw an error
Program will throw an exception
____________ is an exit-controlled loop.
do...while.
while
for
if-else
Loops in C programming are used to ___.
Execute a statement based on a condition
Execute a block of code repeatedly
Create a variable
Create an object
When all cases are unmatched, which case is matched in a switch statement _______
First case
No case
Exception
Default case
A statement is required to execute a block of code when the condition is false.
for
while
if
else
When the condition of the if statement is false, the flow of code will ___.
go into the if block
Exit the program
Continue the code after skipping the if block.
repeat the code
Ternary operator in C programming is ___.
?:
if-else-if
?:?
::
What is the output of the below program? int main() { int i; for(i = 0; i < 5; i++) { printf("Hello"); } return 0; }
Hello is printed 5 times
Hello is printed 4 times
Compilation Error
Runtime error.
Find the output of the following code: int main() { for(;;) printf("Hello.."); return 0; }
Compilation Error
Runtime Error
Hello is printed one time
Hello is printed infinite times
The relational expression 10 > 20 produces
0
1
10
20
The operator = performs
Assignment
Comparison
Logical test
Increment
The expression 10 + 5 * 2 evaluates to ____________.
30
25
20
15
Incorrect format specifiers generally cause
Runtime issue
Syntax error
Linker error
Compile-time error
Storing 5/2 in an integer variable results in:
2
2.5
3
Error
The operator ++ increases a variable by:
2
1
Variable value
Compiler decision
Logical AND operation returns true only when:
One condition is true
Both conditions are true
Both conditions are false
Any condition is false
The operator = performs:
Comparison
Assignment
Logical test
Increment
The conditional operator uses:
::
->
?:
##
The if-else statement supports:
Looping
Decision making
Function calling
File handling
The switch statement is preferred for:
Multiple loops
Multiple conditions
Multiple selections
Multiple files
A while loop checks the condition:
After execution
Before execution
During execution
At compile time
The do-while loop executes at least:
Zero times
One time
Two times
Infinite times
Using %f for printing an integer usually leads to:
Correct output
Automatic conversion
Garbage output
Compilation failure
Multiple if-else statements increase:
Execution speed
Program complexity
Memory optimization
Output accuracy
Infinite loops commonly occur due to:
Missing condition update
Extra semicolon
Compiler error
Data overflow
The break statement inside a loop causes:
Loop repetition
Loop termination
Program restart
Condition skip
The continue statement causes:
Loop exit
Program termination
Skipping the remaining loop body
Infinite looping
Nested loops mainly increase:
Execution clarity
Logical complexity
Compiler speed
Syntax simplicity
Given int x = 5; printf("%d", x++ + ++x); the output is:
10
11
Undefined behavior
12
A loop without a termination condition results in:
Syntax error
Logical error
Infinite execution
Compilation error
Replacing while with for without changing the logic requires preserving:
Loop body only
Initialization, condition, increment
Condition only
Increment only
Using goto extensively makes programs:
Faster
Easier to debug
Difficult to maintain
Memory efficient
A decision taken using ?: instead of if-else results in:
Longer code
Compact expression
Reduced logic
Multiple branches
A relational expression returning a non-zero value is treated as:
False
Error
True
Undefined
A loop controlled by user input mainly risks:
Syntax errors
Infinite looping
Memory overflow
Linker error
Incorrect format specifiers generally cause:
Compile-time error
Runtime issue
Linker error
Syntax error
Decision complexity increases mostly due to:
Nested conditions
Variable size
Data type
Input function
A missing break in a switch statement results in:
Loop termination
Fall-through execution
Compilation error
Program halt
The most suitable loop for known iterations is:
while
do-while
for
goto
The condition while(0) causes:
One execution
Infinite execution
Zero execution
Compilation error
A relational expression used inside an if statement evaluates based on:
Data type
True or false result
Variable size
Operator precedence
A program producing correct output but with wrong logic contains:
Syntax error
Runtime error
Logical error
Linker error
Converting a problem statement into a sequence of logical steps results in:
Flowchart
Algorithm
Source code
Object code
Replacing a flowchart with pseudo-code mainly improves:
Execution speed
Program security
Readability and understanding
Memory allocation
Declaring int x = 5 / 2; stores the value:
2
2.5
3
Compilation error
Executing printf("%d", 10 + 20 * 3); displays:
90
70
60
100
Applying the increment operator twice to a variable in the same expression generally causes:
Predictable output
Faster execution
Undefined behavior
Logical AND operation
The expression (5 > 3) && (10 < 4) evaluates to:
1
0
Compilation error
Garbage value
Using the conditional operator instead of if-else generally results in:
More lines of code
Reduced readability always
Compact single-line decisions
Slower execution
Evaluating int x = (5 > 3) ? 10 : 20; assigns:
5
3
10
20
Printing an integer using %f mostly leads to:
Correct output
Automatic type conversion
Logical error
Runtime error or garbage value
Compilation errors are typically detected during:
Program execution
Debugging stage
Compilation stage
Testing stage
A loop condition checked after execution guarantees:
Zero iterations
At least one iteration
Infinite looping
Conditional branching
Replacing a while loop with a for loop without changing logic requires:
Altering the loop body only
Preserving initialization, condition, and increment
Removing the condition
Adding a goto statement
Exiting a loop immediately upon meeting a condition commonly uses:
continue
goto
break
return
Which of the following is the first step in program development?
Flowchart
Pseudocode
Algorithm
Coding
An algorithm is best described as:
A program written in C
A graphical representation of logic
A step-by-step procedure to solve a problem
A debugging tool
Which of the following is a valid C data type?
real
float
decimal
number
Which data type is used to store a single character in C?
char
string
int
bool
What will be the output of the following code snippet?
#include
b is greater
No output
a is greater
Compilation error
In C, the operator '&&' is used for:
Bitwise OR
Logical OR
Logical AND
Bitwise AND
The main purpose of writing an algorithm before coding in C
To make coding easier by clearly defining the logic
To minimize the size of the program
To improve the speed of execution
To avoid using any loops in the program
The lifetime of a global variable lasts _______________.
Throughout the program's execution.
Until redefined in another function
Until the function ends
For a single loop iteration
A global variable is ________________.
A variable declared outside all functions
A constant declared with `#define`
A variable that has a local scope
A variable declared inside a function
In the `continue` statement, the program:
Skips the remaining statements and starts the next iteration
Restarts the loop from the beginning
Returns to the main function
Breaks out of the loop
In C, the `goto` statement ____________.
Jumps to a labeled statement
Stops the program
Iterates through loops
Moves to the next function
A loop that checks the condition at the end of the loop block is ______________.
`do-while`
`if-else`
`for`
`while`
In C, a switch-case statement ___________________.
Executes a block of code for a specific value.
Can handle floating-point comparisons.
Ends with a `continue` statement.
Evaluates a condition.
1. Who invented the C Language?
Charles Babbage
Graham Bell
Dennis Ritchie
Steve Jobs
4. Find an integer constant
3.145
34
"125"
None of the above
5. Each statement in a C program should end with?
Semicolon ;
Colon :
Period . (dot symbol)
None of the above.
6. Choose the correct statement.
int a = 10 + 4.867;
a = 10
a = 14.867
a = 14
compiler error.
What is the output of the C statement?
int main()
{
int a=0;
a = 5<2 ? 4 : 3;
printf("%d",a);
return 0;
}
4
3
5
2
What is the output of the following C program?
int main()
{
int a = 0;
a = printf("4");
printf("%d", a);
return 0;
}
04
40
compiler error
41
Choose a C Conditional Operator from the list.
?:
:?
:<
<:
Choose a syntax for the C Ternary Operator from the list.
condition ? expression1 : expression2
condition : expression1 ? expression2
condition ? expression1 < expression2
condition < expression1 ? expression2
Output of the following code
#include <stdio.h>
int main()
{ int i = 0;
switch (i)
{
case '0': printf("Geeks");
break;
case '1': printf("Quiz");
break;
default: printf("GeeksQuiz");
}
return 0;
}
Geeks
Quiz
GeeksQuiz
None of the above
The keyword used to transfer control from a function back to the calling function is
switch
goto
go back
return
#include<stdio.h>
int main()
{ int k=1;
printf("%d == 1 is %s\n", k, k==1?"TRUE":"FALSE");
return 0;
}
k == 1 is TRUE
1 == 1 is TRUE
1 == 1 is FALSE
K == 1 is FALSE
int main()
{
if(0);
printf("Hello");
printf("Hi");
return 0;
}
Hi
Hello
HelloHi
Compilation Error
What is the output of the following code?
#include <stdio.h>
int main()
{
if(printf("C programming is"))
{
printf("Easy");
}
else
{
printf("Hard");
}
return 0;
}
C Programming Easy
Easy
Hard
None of these
What is the output of the following code?
#include <stdio.h>
#define Mul(a,b) (a+b*a+b)
int main() {
printf("%d",Mul(2,4));
return 0;
}
36
14
16
8
Output of the following code?
#include <stdio.h>
int main()
{
int a = 12, b = 25;
printf("Output = %d", a & b);
return 0;
}
29
8
21
25
Output of the following code?
#include <stdio.h>
int main()
{
char arr[11]="The African Queen";
printf("%s",arr);
return 0;
}
The African Queen
The
African Queen
Compilation Error
Output of the following code?
#include <stdio.h>
int main()
{
char arr[20]="The African Queen";
printf("%s",arr);
return 0;
}
The African Queen
The
African Queen
Compilation Error
Output of the following code?
#include <stdio.h>
int main()
{
int a = 1, b = 1, c;
c = a++ + b;
printf("%d, %d", a, b);
}
a = 1, b = 1
a = 2, b = 1
a = 1, b = 2
a = 2, b = 2
Find the output of the following code:
int main ()
{
int a, b;
a = b = 4;
b = a++;
printf("%d %d %d %d", a++, --b, ++a, b--);
}
5 3 73
5 4 5 3
6 2 6 4
Syntax Error
Find the error/output in the following code
int main ()
{
static int num = 8;
printf ("%d", num = num - 2);
if (num != 0)
main();
}
8 6 4 2
Infinite output
Invalid because the main function can't call itself
6 4 2 0
Find the error/output in the following code
int main ()
{
int a = 10, b = 25;
a = b++ + a++;
b = ++b + ++a;
printf ("%d %d\n", a, b);
}
36 64
35 62
36 63
30 28
Find the error/output in the following code:
void fn ()
{
static int i = 10;
printf ("%d", ++i);
}
int main ()
{
fn();
fn();
}
10 10
11 12
11 11
12 12
Find the error/output in the following code:
int main ()
{
int m = -10, n = 20;
n = (m < 0) ? 0 : 1;
printf("%d %d", m, n);
}
-10 0
10 20
20 -10
0 1
Find the error/output in the following code:
int main ()
{
int i = 0;
for ( ; ;)
printf ( "%d", i);
return 0;
}
0 times
Infinite times
10 times
1 time
Find the error/output in the following code:
int main ()
{
int x = 1;
while (x = 0)
printf ("Hello");
}
Hello
No output
Infinite time Hello display
Error in code
Find the error/output in the following code:
int main ()
{
int x = 0, y = 0;
if (x > 0)
if (y > 0)
printf ("True");
else
printf ("False");
}
No output
True
False
Error because of dangling else problem
Find the error/output in the following code
void main ()
{
int a = 1, b = 2, c = 3;
char d = 0;
if (a, b, c, d)
{
printf ("EXAM");
}
}
No output and no error
EXAM
Runtime error
Compile time error
All keywords in C are in ____________
Lowercase letters
Uppercase letters
Numeric letters
Alphanumeric letters
What is the output of the following C program?
int main()
{
int a=32;
do
{
printf("%d ", a);
a++;
}
while(a <= 30);
return 0;
}
32
33
30
No Output
Which is the only function all C programs must contain?
start()
sys()
main()
scanf()
What is the output if the user enters:
Yes?
Leave umbrella at home
Take an umbrella
What do you think is the output of the code snippet below?
int main(){
int a=10,b=20;
printf("%d", b/a);
}
Error
0.2
2
30
Find if the condition is True or False where int x=10; y=12;
x < y
1 (True)
0 (False)
Which function is correct?
void function() { }
function[] { }
function({ })
void function[]()
The switch statement takes a given integer value and seeks a matching value among a number of _______ statements.
break
case
switch
goto
How many loops are there in C?
1
3
2
4
The output of the following segment is
int k, n=20;
k=(n>5?(n<=10?100:200):500);
printf("%d",n);
100
200
300
20
What will print?
s
m
d
e
What will print?
0
1
5
10
What will print?
0
6
100
none of these
What is printed?
nothing
0
6
100
What will print?
0
1
10
100
What will print?
0
1
100
101
What will print?
0
1
100
101
What will print?
10
20
30
40
