Font size
WorksheetsC programming Basics
Total questions: 20
Worksheet time: 20mins
Which of the following are valid variable names in C?
first_name
123name
_count
#value
Which of these are basic data types in C?
int
float
char
string
Which are arithmetic operators in C?
%
/
*
+
-
Which header file is required for using printf function?
#include<math.h>
#include<conio.h>
#include<stdio.h>
#include<string.h>
Which symbols are used for single line comments in C?
//
/* message */
--
#
What is the purpose of scanf() function?
Clear screen
Exit program
Read input
Print output
Which is the correct way to declare and initialize an integer variable?
age=20
var age=20
integer age=20
int age=20
What are essential parts of a C program?
Header files
Main function
Variables
Classes
Where is semicolon (;) required in C programs?
Preprocessor directives
End of statement
Header inclusion
Function declaration
Which format specifier is used for integers in printf?
%s
%d
%f
%c
How many bytes does a char data type occupy?
2 bytes
8 bytes
4 bytes
1 byte
Which rules apply to C identifiers?
Can start with number
Can start with letter
Can contain spaces
Can use keywords
Which symbols are used for code blocks in C?
begin-end
[ ]
{ }
( )
5 5
5 10
10 10
10 5
24
14
20
error
printf("%d", -5 % 2);
-1
1
-2
Compiler dependent
Which function is used to print output in C programming?
cout
printf()
write()
scanf()
in which extension we need to save the program to run on c compiler.
filename.cpp
filename.c
filename.jpeg
filename.o
Which is a valid variable name in C?
#variable
123variable
my variable
my_variable
What is the scope of a local variable?
Within function
Within file
Entire program
Within block
