stud
bud
Sign up
Log in
Home
Library
Explore
SAT
More
Y-9 Unit-12 Introduction to C Programming (I) Flashcards | StudBud
Explore
/
Y-9 Unit-12 Introduction to C Programming (I)
Y-9 Unit-12 Introduction to C Programming (I)
30 terms
·
StudBud Administration
Imported from external platform
Flashcards
30 cards
F
Practice quiz
P
Host live
L
Questions
30
Answers
1
What will be printed by the following code?
Age: 23 Grade: B
Age: 23, Grade: B
Age: %d, Grade: %c
Age: 23, Grade: %d
2
How do you
declare
multiple variables
of the
same type
in "C" programming?
Declare each variable on a new line
Separate each variable with a semicolon
Use square brackets around variable names
Use a comma-separated list
3
Given the following code:
D
100
68
'D'
4
Which data type is suitable for storing a
student’s grade
(e.g., 'B')?
float
int
char
string
5
What characters can variable names in C programming contain?
Letters, digits, and underscores
Letters, digits, and special characters
Digits and special characters only
Letters and spaces
6
Which of the following lines correctly assigns the value of one variable to another?
myOtherNum = myNum;
myNum = 15 == myOtherNum;
myNum == myOtherNum;
7
How do you print both a
number
and a
character
in the same printf( ) function in C?
printf("%d, %c", myNum, myChar);
printf("%d %c", myNum, myChar);
printf("%d %f %c", myNum, myChar, myNum);
printf("%c, %d", myLetter, myChar);
8
What is the purpose of
format specifiers
in C programming?
To tell the compiler the type of data a variable is storing
To print strings
To perform mathematical operations
To declare variables
9
What
format specifier
is used to print an
integer value
in C?
%d
%s
%f
%c
10
What is the purpose of using variable names like
studentID
and
studentAge
in programs?
To match the format specifiers
To reduce the number of variables used
To avoid confusion and provide meaningful context
To ensure all variables are of the same data type
11
What will be printed by the following code?
15
My favorite number is: myNum
My favorite number is: 15
My favorite number is: %d
12
What will the following code output?
15 5.999999
15 5.99
15 5.99.0
15 5
13
What will the following code output?
20
An error
60
40
14
What happens when you assign a new value to an existing variable in C?
The new value is ignored
The previous value is overwritten
An error occurs
The previous value is deleted, and the variable is cleared
15
How would you declare three integer variables '
a
', '
b
', and '
c
' with values
1
,
2
, and
3
in a single line?
int a, b, c = 1, 2, 3;
int a 1, b 2, c 3;
int a = 1; int b = 2; int c = 3;
int a = 1, b = 2, c = 3;
16
Which format specifier is used to print
an integer in C
?
%s
%d
%f
%c
17
What will the following code output?
5
61
5650
6
18
Which format specifier is used to print a
floating-point number
in C?
%d
%f
%i
%c
19
What does the following code do?
Assigns different values to each variable
Declares variables without assigning values
Throws an error
Assigns 50 to x, y, and z
20
What is the correct way to declare and initialize the variable
x
to display the sum of
5 + 10
in the following code?
int x = 5;
x = 5;
int x + 5;
int x == 5;
21
What is the correct format specifier to output the value of
myNum
in the following code?
%s
%c
%f
%d
22
What is a recommended practice when
naming variables
in C?
Use simple and clear names to create understandable code.
Use reserved words as variable names.
Use short, single-letter names like x and y.
23
What will the following code output?
StudentID: 15
15
Student id: 15
Student id: %d
24
What is an example of a
descriptive variable name
?
int x = 10;
int _ = 5;
int m = 60;
int totalAmount = 100;
25
What will the following code output?
10
An error
15
%d
26
What will happen if you try to use a
reserved word(
a special meaning
like
int
,
return
, or
if )
as a variable name?
The variable will be created with no issues.
The compiler will throw an error.
The reserved word will automatically change.
The compiler will ignore it.
27
What will the following code output?
6
An error
11
5
28
What is the correct format specifier to print the value of
studentFee
?
%f
%s
%c
%d
29
You can print a value directly in printf( ) without using a variable, as long as the correct format specifier is used.
False
True
30
What will the following code output?
23
15
An error
myOtherNum