wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

CIS1101-programming practice

Total questions: 15

Worksheet time: 8mins

Name
Class
Date
1.

What is the output of the following code snippet?
char ch;

for(ch='a'; ch<='z'; ch++)

{

printf("%c\n", ch);

}

a)

The program will display the alphabet from a to z

b)

The program will display the alphabet from A to Z

c)

The program will display the alphabet from A and Z

d)

The program will display the alphabet from a and z

e)

The program will display the alphabet from a or z

2.

What is the output of the following code snippet?
int i, n=100;

for(i=1; i<=n; i++) {

printf("%d\n", i);

}

a)

The program will display the numbers from 1 and 100

b)

The program will display the numbers from 1 or 100

c)

The program will display the numbers from 1 to 100

d)

The program will display the numbers from 1 by 100

e)

The program will display the numbers from 1 on 100

3.

What is the output of the following code snippet?
int i, start=50;

printf("Enter starting value: ");

scanf("%d", &start);

for(i=start; i>=1; i--){

printf("%d\n", i); }

a)

The program will display the numbers from 50 by 1

b)

The program will display the numbers from 50 or 1

c)

The program will display the numbers from 50 and 1

d)

The program will display the numbers from 50 to 0

e)

The program will display the numbers from 50 to 1

4.

What is the output of the following code snippet?
int i, n=1000;

printf("Print all even numbers till: ");

scanf("%d", &n);

printf("Even numbers from 1 to %d are: \n", n);

for(i=1; i<=n; i++) {

if(i%2 == 0){

printf("%d\n", i);

}}

a)

The program will display some even numbers from 1-1000

b)

The program will display few even numbers from 1-1000

c)

The program will display all even numbers from 1-1000

d)

The program will display more even numbers from 1-1000

e)

The program will display much even numbers from 1-1000

5.

What is the output of the following code snippet?
int i, n=500;

for(i=1; i<=n; i++) {

if(i%2!=0) {

printf("%d\n", i);

} }

a)

The program will display some odd numbers from 1-500

b)

The program will display all odd numbers from 1-500

c)

The program will display much odd numbers from 1-500

d)

The program will display more odd numbers from 1-500

e)

The program will display many odd numbers from 1-500

6.

What is the output of the following code snippet?
char gender='f';

if(gender=='m')

printf("male");

else if(gender=='f')

printf("female");

else

printf("invalid");

a)

The program display male, female, or invalid depending on the gender char input

b)

The program get male, female, or invalid depending on the gender char input

c)

The program display male, female depending on the gender char input

d)

The program display male and female and invalid depending on the gender char input

e)

The program display female, or invalid depending on the gender char input

7.

#include <stdio.h>

int main() {

printf("hello world\n");

return 0;

}

a)

The code in red is known as the function header

b)

The code in red is known as the function parameter

c)

The code in red is known as the function name

d)

The code in red is known as the return type

e)

The code in red is known as the library or preprocessor

8.

#include <stdio.h>

int main() {

printf("hello world\n");

return 0;

}

a)

The code in red is known as the function header

b)

The code in red is known as the function parameter

c)

The code in red is known as the function name

d)

The code in red is known as the return type

e)

The code in red is known as the library or preprocessor

9.

#include <stdio.h>

int main() {

printf("hello world\n");

return 0;

}

a)

The code in red is known as the function header

b)

The code in red is known as the function parameter

c)

The code in red is known as the function name

d)

The code in red is known as the return type

e)

The code in red is known as the library or preprocessor

10.

#include <stdio.h>

int main() {

printf("hello world\n");

return 0;

}

a)

The code in red is known as the function header

b)

The code in red is known as the function parameter

c)

The code in red is known as the function name

d)

The code in red is known as the return type

e)

The code in red is known as the library or preprocessor

11.

#include <stdio.h>

int main() {

printf("hello world\n");

return 0;

}

a)

The code in red is known as the function header

b)

The code in red is known as the function parameter

c)

The code in red is known as the function name

d)

The code in red is known as the return type

e)

The code in red is known as the library or preprocessor

12.

#include <stdio.h>

int main() {

printf("hello world\n");

return 0;

}

a)

The code in red is known as a built-in function in C

b)

The code in red is known as the return statement

c)

The code in red is known as the function header

d)

The code in red is known as the function parameter

e)

The code in red is known as the body of the function

13.

#include <stdio.h>

int main() {

printf("hello world\n");

return 0;

}

a)

The code in red is known as a built-in function in C

b)

The code in red is known as the return statement

c)

The code in red is known as the function header

d)

The code in red is known as the function parameter

e)

The code in red is known as the body of the function

14.

#include <stdio.h>

int main() {

printf("hello world\n");

return 0;

}

a)

The code in red is known as a built-in function in C

b)

The code in red is known as the return statement

c)

The code in red is known as the function header

d)

The code in red is known as the function parameter

e)

The code in red is known as the body of the function

15.

In the code

int n=5, j;

for(j=1;j<=10;j++) {

printf("%d X %d = %d \n",n,j,n*j);

}

What is the value of n, j and n*j on the third iteration?

a)

5, 3, 15

b)

3, 5, 15

c)

5, 5, 15

d)

3, 3, 15

e)

3, 5, 9