C Programming

VARIABLE DECLARATIONS AND DATA TYPES MULTIPLE CHOICE QUESTIONS

1

In many languages, what is the primary purpose of "declaring" a variable?

A.

To delete it from the computer's memory

B.

To tell the computer the name and type of data the variable will hold

C.

To display the value of the variable on the screen

D.

To perform a mathematical calculation

2

Which of the following is a valid variable name in most programming languages?

A.

2nd_place

B.

user-name

C.

total_amount

D.

class

3

Which of the following best describes a "constant"?

A.

A value that can be updated any time during program execution.

B.

A named memory location whose value cannot be changed once assigned.

C.

A type of variable that only stores text.

D.

A reserved word used to define a new function

4

What happens if you try to reassign a value to a constant after its initial assignment?

A.

The program will automatically create a new variable.

B.

The value will change without any issues.

C.

The program will ignore the new value.

D.

The compiler or interpreter will likely throw an error.

A programmer wants to build a simple software to calculate the basic salary of workers.

Use the above information to answer questions 5 to 7.

5

What data type will she use for the salary input in the program?

A.

int

B.

double

C.

char

D.

bool

6

What c programming function will she use to instruct a user to enter his/her hours worked?

A.

scanf

B.

define

C.

printf

D.

display

7

What c programming function will she use to store the entered hours?

A.

scanf

B.

define

C.

printf

D.

get

8

A programmer wishes to use M for male and F for female. Which of the following data types will be appropriate to use?

A.

char

B.

int

C.

double

D.

float