wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

C Programming and Flowchart Basics – Worksheet Extraction

Total questions: 150

Worksheet time: 2hrs 31mins

Name
Class
Date
1.

_______ is the symbol typically used in a flowchart to represent a decision point.

a)

Rectangle

b)

Diamond

c)

Oval

d)

Circle

2.

The first step in solving a programming problem is:

a)

Coding

b)

Testing

c)

Algorithm

d)

Debugging

3.

A flowchart mainly represents:

a)

Program syntax

b)

Logical flow of execution

c)

Machine instructions

d)

Compiler rules

4.

______________ is the symbol typically used in a flowchart to represent the end of the program.

a)

Oval

b)

Diamond

c)

Rectangle

d)

Circle

5.

Pseudo-code is written using:

a)

Binary language

b)

Programming syntax

c)

English-like statements

d)

Machine code

6.

The main purpose of writing an algorithm before coding in C

a)

To minimize the size of the program

b)

To improve the speed of execution

c)

To make coding easier by clearly defining the logic

d)

To avoid using any loops in the program

7.

The data type used to store integer values is:

a)

float

b)

char

c)

int

d)

double

8.

The size of the char data type is:

a)

2 bytes

b)

4 bytes

c)

1 byte

d)

8 bytes

9.

A constant value in C remains:

a)

Modifiable

b)

Fixed during execution

c)

Input dependent

d)

Compiler dependent

10.

A valid variable name in C is __________

a)

float

b)

1stnumber

c)

score#

d)

_score

11.

A valid C variable name is:

a)

total-marks

b)

1value

c)

total_marks

d)

float

12.

The lifetime of a global variable lasts _______________.

a)

Throughout the program's execution.

b)

Until redefined in another function.

c)

Until the function ends.

d)

For a single loop iteration.

13.

The function used for output is:

a)

scanf()

b)

printf()

c)

input()

d)

output()

14.

The symbol %d is used for:

a)

float

b)

character

c)

integer

d)

string

15.

The operator + belongs to:

a)

Logical

b)

Relational

c)

Arithmetic

d)

Conditional

16.

The correct symbol for the modulus operator in C is ______.

a)

/

b)

%

c)

||

d)

!=

17.

A global variable is _______________.

a)

A variable declared outside all functions

b)

A constant declared with '#define'

c)

A variable that has a local scope

d)

A variable declared inside a function

18.

In C, the `goto` statement ____________.

a)

Stops the program

b)

Iterates through loops

c)

Jumps to a labeled statement

d)

Moves to the next function

19.

A loop that checks the condition at the end of the loop block is ______________.

a)

do-while

b)

if-else

c)

for

d)

while

20.

In a nested `if` statement, the condition that will be executed depends on ______________.

a)

The value of a global variable

b)

Both outer and inner conditions

c)

The deepest nested condition

d)

The first condition only

21.

In C, a switch-case statement __________________.

a)

Can handle floating-point comparisons.

b)

Executes a block of code for a specific value.

c)

Ends with a `continue` statement.

d)

Evaluates a condition.

22.

The result of the expression 10/310 / 3 in C, when both operands are integers, is __________.

a)

4

b)

3.33

c)

3

d)

3.0

23.

The precedence of arithmetic operators is (from highest to lowest):

a)

+, -, %, *, /

b)

%, *, /, +, −

c)

%, +, /, *, -

d)

%, +, -, *, /

24.

Identify the logical operator in C.

a)

==

b)

=-

c)

+=

d)

&&

25.

Output of the following #include int main() { int x = 1, y = 0; if (x && y) { printf("Both are true\n"); } else { printf("At least one is false\n"); } return 0; }

a)

Both are true

b)

At least one is false

c)

Compilation error

d)

Logical error

26.

Compute the output for the following code: #include int main() { int a = 10, b = 5; if (a > b) if (b > 0) printf("b is positive\n"); else printf("b is negative\n"); printf("a is greater than b\n"); return 0; }

a)

b is positive

b)

a is greater than b

c)

b is non-positive

27.

Identify the correct assignment:

a)

100=a=b=c;

b)

a=100=b=c;

c)

a=b=c=100;

d)

a=b=100=c;

28.

Char type uses ________ bytes.

a)

1

b)

2

c)

3

d)

4

29.

For which type is the format specifier "%i" used?

a)

char

b)

float

c)

int

d)

number

30.

The difference between float and double in C

a)

Both are used for the same purpose.

b)

Double is more precise than float and can store 64 bits.

c)

Double can store just double values compared to float values.

d)

Double is an enhanced version of float and was introduced in C#.

31.

__________ is not an arithmetic expression in C

a)

x != 10

b)

x %= 10

c)

x /= 10

d)

x = 10

32.

Compute the output of the following snippet: #include int main() { int x = 20; x %= 3; printf("%d",x); return 0; }

a)

2

b)

2.5

c)

error

d)

warning

33.

_______ format specifier is used to read and print a string using printf() and scanf() in C.

a)

%str

b)

%s

c)

%c

d)

%p

34.

Identify the valid syntax for creating a while loop.

a)

while { } (condition)

b)

while { }

c)

while(condition) { }

d)

condition { while() }

35.

Give the output of the following C code. #include int main() { int a = 11; while (a < 20) { printf("%d ", a); a += 2; } return 0; }

a)

11 12 13 14 15 16 17 18 19 20

b)

11 13 15 17 19 21

c)

11 13 15 17 19

d)

12 14 16 18 20

36.

Which of these statements is correct in the case of a while loop in C?

a)

Executes the block until the condition becomes false.

b)

Is an exit-controlled loop.

c)

There might be a condition when the loop will execute at least once.

d)

The loop will increment only by +1.

37.

______________ if the loop condition never becomes false.

a)

Loop will not run

b)

Program will loop infinitely

c)

Program will throw an error

d)

Program will throw an exception

38.

____________ is an exit-controlled loop.

a)

do...while.

b)

while

c)

for

d)

if-else

39.

Loops in C programming are used to ___.

a)

Execute a statement based on a condition

b)

Execute a block of code repeatedly

c)

Create a variable

d)

Create an object

40.

When all cases are unmatched, which case is matched in a switch statement _______

a)

First case

b)

No case

c)

Exception

d)

Default case

41.

A statement is required to execute a block of code when the condition is false.

a)

for

b)

while

c)

if

d)

else

42.

When the condition of the if statement is false, the flow of code will ___.

a)

go into the if block

b)

Exit the program

c)

Continue the code after skipping the if block.

d)

repeat the code

43.

Ternary operator in C programming is ___.

a)

?:

b)

if-else-if

c)

?:?

d)

::

44.

What is the output of the below program? int main() { int i; for(i = 0; i < 5; i++) { printf("Hello"); } return 0; }

a)

Hello is printed 5 times

b)

Hello is printed 4 times

c)

Compilation Error

d)

Runtime error.

45.

Find the output of the following code: int main() { for(;;) printf("Hello.."); return 0; }

a)

Compilation Error

b)

Runtime Error

c)

Hello is printed one time

d)

Hello is printed infinite times

46.

The relational expression 10 > 20 produces

a)

0

b)

1

c)

10

d)

20

47.

The operator = performs

a)

Assignment

b)

Comparison

c)

Logical test

d)

Increment

48.

The expression 10 + 5 * 2 evaluates to ____________.

a)

30

b)

25

c)

20

d)

15

49.

Incorrect format specifiers generally cause

a)

Runtime issue

b)

Syntax error

c)

Linker error

d)

Compile-time error

50.

Storing 5/25/2 in an integer variable results in:

a)

2

b)

2.5

c)

3

d)

Error

51.

The operator ++ increases a variable by:

a)

2

b)

1

c)

Variable value

d)

Compiler decision

52.

Logical AND operation returns true only when:

a)

One condition is true

b)

Both conditions are true

c)

Both conditions are false

d)

Any condition is false

53.

The operator = performs:

a)

Comparison

b)

Assignment

c)

Logical test

d)

Increment

54.

The conditional operator uses:

a)

::

b)

->

c)

?:

d)

##

55.

The if-else statement supports:

a)

Looping

b)

Decision making

c)

Function calling

d)

File handling

56.

The switch statement is preferred for:

a)

Multiple loops

b)

Multiple conditions

c)

Multiple selections

d)

Multiple files

57.

A while loop checks the condition:

a)

After execution

b)

Before execution

c)

During execution

d)

At compile time

58.

The do-while loop executes at least:

a)

Zero times

b)

One time

c)

Two times

d)

Infinite times

59.

Using %f for printing an integer usually leads to:

a)

Correct output

b)

Automatic conversion

c)

Garbage output

d)

Compilation failure

60.

Multiple if-else statements increase:

a)

Execution speed

b)

Program complexity

c)

Memory optimization

d)

Output accuracy

61.

Infinite loops commonly occur due to:

a)

Missing condition update

b)

Extra semicolon

c)

Compiler error

d)

Data overflow

62.

The break statement inside a loop causes:

a)

Loop repetition

b)

Loop termination

c)

Program restart

d)

Condition skip

63.

The continue statement causes:

a)

Loop exit

b)

Program termination

c)

Skipping the remaining loop body

d)

Infinite looping

64.

Nested loops mainly increase:

a)

Execution clarity

b)

Logical complexity

c)

Compiler speed

d)

Syntax simplicity

65.

Given int x = 5; printf("%d", x++ + ++x); the output is:

a)

10

b)

11

c)

Undefined behavior

d)

12

66.

A loop without a termination condition results in:

a)

Syntax error

b)

Logical error

c)

Infinite execution

d)

Compilation error

67.

Replacing while with for without changing the logic requires preserving:

a)

Loop body only

b)

Initialization, condition, increment

c)

Condition only

d)

Increment only

68.

Using goto extensively makes programs:

a)

Faster

b)

Easier to debug

c)

Difficult to maintain

d)

Memory efficient

69.

A decision taken using ?: instead of if-else results in:

a)

Longer code

b)

Compact expression

c)

Reduced logic

d)

Multiple branches

70.

A relational expression returning a non-zero value is treated as:

a)

False

b)

Error

c)

True

d)

Undefined

71.

A loop controlled by user input mainly risks:

a)

Syntax errors

b)

Infinite looping

c)

Memory overflow

d)

Linker error

72.

Incorrect format specifiers generally cause:

a)

Compile-time error

b)

Runtime issue

c)

Linker error

d)

Syntax error

73.

Decision complexity increases mostly due to:

a)

Nested conditions

b)

Variable size

c)

Data type

d)

Input function

74.

A missing break in a switch statement results in:

a)

Loop termination

b)

Fall-through execution

c)

Compilation error

d)

Program halt

75.

The most suitable loop for known iterations is:

a)

while

b)

do-while

c)

for

d)

goto

76.

The condition while(0) causes:

a)

One execution

b)

Infinite execution

c)

Zero execution

d)

Compilation error

77.

A relational expression used inside an if statement evaluates based on:

a)

Data type

b)

True or false result

c)

Variable size

d)

Operator precedence

78.

A program producing correct output but with wrong logic contains:

a)

Syntax error

b)

Runtime error

c)

Logical error

d)

Linker error

79.

Converting a problem statement into a sequence of logical steps results in:

a)

Flowchart

b)

Algorithm

c)

Source code

d)

Object code

80.

Replacing a flowchart with pseudo-code mainly improves:

a)

Execution speed

b)

Program security

c)

Readability and understanding

d)

Memory allocation

81.

Declaring int x = 5 / 2; stores the value:

a)

2

b)

2.5

c)

3

d)

Compilation error

82.

Executing printf("%d", 10 + 20 * 3); displays:

a)

90

b)

70

c)

60

d)

100

83.

Applying the increment operator twice to a variable in the same expression generally causes:

a)

Predictable output

b)

Faster execution

c)

Undefined behavior

d)

Logical AND operation

84.

The expression (5 > 3) && (10 < 4) evaluates to:

a)

1

b)

0

c)

Compilation error

d)

Garbage value

85.

Using the conditional operator instead of if-else generally results in:

a)

More lines of code

b)

Reduced readability always

c)

Compact single-line decisions

d)

Slower execution

86.

Evaluating int x = (5 > 3) ? 10 : 20; assigns:

a)

5

b)

3

c)

10

d)

20

87.

Printing an integer using %f mostly leads to:

a)

Correct output

b)

Automatic type conversion

c)

Logical error

d)

Runtime error or garbage value

88.

Compilation errors are typically detected during:

a)

Program execution

b)

Debugging stage

c)

Compilation stage

d)

Testing stage

89.

A loop condition checked after execution guarantees:

a)

Zero iterations

b)

At least one iteration

c)

Infinite looping

d)

Conditional branching

90.

Replacing a while loop with a for loop without changing logic requires:

a)

Altering the loop body only

b)

Preserving initialization, condition, and increment

c)

Removing the condition

d)

Adding a goto statement

91.

Exiting a loop immediately upon meeting a condition commonly uses:

a)

continue

b)

goto

c)

break

d)

return

92.

Which of the following is the first step in program development?

a)

Flowchart

b)

Pseudocode

c)

Algorithm

d)

Coding

93.

An algorithm is best described as:

a)

A program written in C

b)

A graphical representation of logic

c)

A step-by-step procedure to solve a problem

d)

A debugging tool

94.

Which of the following is a valid C data type?

a)

real

b)

float

c)

decimal

d)

number

95.

Which data type is used to store a single character in C?

a)

char

b)

string

c)

int

d)

bool

96.

What will be the output of the following code snippet? #include int main() { int a = 5, b = 10; if (a > b) printf("a is greater"); else printf("b is greater"); return 0; }

a)

b is greater

b)

No output

c)

a is greater

d)

Compilation error

97.

In C, the operator '&&' is used for:

a)

Bitwise OR

b)

Logical OR

c)

Logical AND

d)

Bitwise AND

98.

The main purpose of writing an algorithm before coding in C

a)

To make coding easier by clearly defining the logic

b)

To minimize the size of the program

c)

To improve the speed of execution

d)

To avoid using any loops in the program

99.

The lifetime of a global variable lasts _______________.

a)

Throughout the program's execution.

b)

Until redefined in another function

c)

Until the function ends

d)

For a single loop iteration

100.

A global variable is ________________.

a)

A variable declared outside all functions

b)

A constant declared with `#define`

c)

A variable that has a local scope

d)

A variable declared inside a function

101.

In the `continue` statement, the program:

a)

Skips the remaining statements and starts the next iteration

b)

Restarts the loop from the beginning

c)

Returns to the main function

d)

Breaks out of the loop

102.

In C, the `goto` statement ____________.

a)

Jumps to a labeled statement

b)

Stops the program

c)

Iterates through loops

d)

Moves to the next function

103.

A loop that checks the condition at the end of the loop block is ______________.

a)

`do-while`

b)

`if-else`

c)

`for`

d)

`while`

104.

In C, a switch-case statement ___________________.

a)

Executes a block of code for a specific value.

b)

Can handle floating-point comparisons.

c)

Ends with a `continue` statement.

d)

Evaluates a condition.

105.

1. Who invented the C Language?

a)

Charles Babbage

b)

Graham Bell

c)

Dennis Ritchie

d)

Steve Jobs

106.

4. Find an integer constant

a)

3.145

b)

34

c)

"125"

d)

None of the above

107.

5. Each statement in a C program should end with?

a)

Semicolon ;

b)

Colon :

c)

Period . (dot symbol)

d)

None of the above.

108.

6. Choose the correct statement.

int a = 10 + 4.867;

a)

a = 10

b)

a = 14.867

c)

a = 14

d)

compiler error.

109.

What is the output of the C statement?

int main()

{

int a=0;

a = 5<2 ? 4 : 3;

printf("%d",a);


return 0;

}

a)

4

b)

3

c)

5

d)

2

110.

What is the output of the following C program?

int main()

{

int a = 0;

a = printf("4");

printf("%d", a);


return 0;

}

a)

04

b)

40

c)

compiler error

d)

41

111.

Choose a C Conditional Operator from the list.

a)

?:

b)

:?

c)

:<

d)

<:

112.

Choose a syntax for the C Ternary Operator from the list.

a)

condition ? expression1 : expression2

b)

condition : expression1 ? expression2

c)

condition ? expression1 < expression2

d)

condition < expression1 ? expression2

113.

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;

}

a)

Geeks

b)

Quiz

c)

GeeksQuiz

d)

None of the above

114.

The keyword used to transfer control from a function back to the calling function is

a)

switch

b)

goto

c)

go back

d)

return

115.

#include<stdio.h>

int main()

{ int k=1;

printf("%d == 1 is %s\n", k, k==1?"TRUE":"FALSE");

return 0;

}

a)

k == 1 is TRUE

b)

1 == 1 is TRUE

c)

1 == 1 is FALSE

d)

K == 1 is FALSE

116.

int main()

{

if(0);

printf("Hello");

printf("Hi");

return 0;

}

a)

Hi

b)

Hello

c)

HelloHi

d)

Compilation Error

117.

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;

}

a)

C Programming Easy

b)

Easy

c)

Hard

d)

None of these

118.

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;

}

a)

36

b)

14

c)

16

d)

8

119.

Output of the following code?


#include <stdio.h>

int main()

{

int a = 12, b = 25;

printf("Output = %d", a & b);

return 0;

}

a)

29

b)

8

c)

21

d)

25

120.

Output of the following code?


#include <stdio.h>

int main()

{

char arr[11]="The African Queen";

printf("%s",arr);

return 0;

}

a)

The African Queen

b)

The

c)

African Queen

d)

Compilation Error

121.

Output of the following code?


#include <stdio.h>

int main()

{

char arr[20]="The African Queen";

printf("%s",arr);

return 0;

}

a)

The African Queen

b)

The

c)

African Queen

d)

Compilation Error

122.

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)

a = 1, b = 1

b)

a = 2, b = 1

c)

a = 1, b = 2

d)

a = 2, b = 2

123.

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--);

}

a)

5 3 73

b)

5 4 5 3

c)

6 2 6 4

d)

Syntax Error

124.

Find the error/output in the following code

int main ()

{

static int num = 8;

printf ("%d", num = num - 2);

if (num != 0)

main();

}

a)

8 6 4 2

b)

Infinite output

c)

Invalid because the main function can't call itself

d)

6 4 2 0

125.

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);

}

a)

36 64

b)

35 62

c)

36 63

d)

30 28

126.

Find the error/output in the following code:

void fn ()

{

static int i = 10;

printf ("%d", ++i);

}

int main ()

{

fn();

fn();

}

a)

10 10

b)

11 12

c)

11 11

d)

12 12

127.

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);

}

a)

-10 0

b)

10 20

c)

20 -10

d)

0 1

128.

Find the error/output in the following code:

int main ()

{

int i = 0;

for ( ; ;)

printf ( "%d", i);

return 0;

}

a)

0 times

b)

Infinite times

c)

10 times

d)

1 time

129.

Find the error/output in the following code:

int main ()

{

int x = 1;

while (x = 0)

printf ("Hello");

}

a)

Hello

b)

No output

c)

Infinite time Hello display

d)

Error in code

130.

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");

}

a)

No output

b)

True

c)

False

d)

Error because of dangling else problem

131.

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");

}

}

a)

No output and no error

b)

EXAM

c)

Runtime error

d)

Compile time error

132.

All keywords in C are in ____________

a)

Lowercase letters

b)

Uppercase letters

c)

Numeric letters

d)

Alphanumeric letters

133.

What is the output of the following C program?

int main()

{

int a=32;

do

{

printf("%d ", a);

a++;

}

while(a <= 30);

return 0;

}

a)

32

b)

33

c)

30

d)

No Output

134.

Which is the only function all C programs must contain?

a)

start()

b)

sys()

c)

main()

d)

scanf()

135.

What is the output if the user enters:
Yes?

a)

Leave umbrella at home

b)

Take an umbrella

136.
What is an algorithm?
a)
A problem
b)
A solution to a problem
c)
The steps that are taken to solve a problem
d)
The words to enter when typing
137.

What do you think is the output of the code snippet below?

int main(){

int a=10,b=20;

printf("%d", b/a);

}

a)

Error

b)

0.2

c)

2

d)

30

138.

Find if the condition is True or False where int x=10; y=12;

x < y

a)

1 (True)

b)

0 (False)

139.

Which function is correct?

a)

void function() { }

b)

function[] { }

c)

function({ })

d)

void function[]()

140.

The switch statement takes a given integer value and seeks a matching value among a number of _______ statements.

a)

break

b)

case

c)

switch

d)

goto

141.

How many loops are there in C?

a)

1

b)

3

c)

2

d)

4

142.

The output of the following segment is

int k, n=20;

k=(n>5?(n<=10?100:200):500);

printf("%d",n);

a)

100

b)

200

c)

300

d)

20

143.

What will print?

a)

s

b)

m

c)

d

d)

e

144.

What will print?

a)

0

b)

1

c)

5

d)

10

145.

What will print?

a)

0

b)

6

c)

100

d)

none of these

146.

What is printed?

a)

nothing

b)

0

c)

6

d)

100

147.

What will print?

a)

0

b)

1

c)

10

d)

100

148.

What will print?

a)

0

b)

1

c)

100

d)

101

149.

What will print?

a)

0

b)

1

c)

100

d)

101

150.

What will print?

a)

10

b)

20

c)

30

d)

40