Question Bank
1. What do you mean by Data Type?
Cist various data types available in C
language.
2. WWhat is an identifier (variable)? What are the rules to
constrvct an
identifier?
3. What do you mean by an operator in C? Cist the variovs
types of
operators available in Clanguage.
4. What do you mean by Data Type? Cist various data types available in C
language along with their allocated sizes and the corresponding format
specifiers used with the.
S. Explain the difference between while and do-while loop with syntax and
suitable examples.
6. What are different types of Jumpstatementr? Explain each with
suitable examples.
7. Diferen tiate betwpeh celeetion ct
Ans 1Data Type in C:
In C, a data type defines the type of data a variable can hold. Various data
types inclvde int, float, double, char, and more.
Ans 2Tdentfer (Variable) in C:
An identifier in Cis a name given to a variable, function, or any other
user-defined item. Rules for constructing identifiers incvde starting with a
letter, followed by letters, digits, or underscores.
Ans 3 Operafor in C:
An operator in Cperforms operations on variables and values. Types of
operafors include arithmetie, relational, logical, bitwise, assignment, and
more.
Ans Data Types in with Sizes and Format Specifiers:
int (4 bytes, %4)
float (4 bytes, %F)
double (8 bytes, %iF)
char (1 byte, %e)
long (4 or 8 bytes, %ld)
Anss Dierence between while and do-while loop:
while loop: Executes statements while the condition is true.
while (eondition) {
I/ statements
while loop: Executes statements while the conditio is true.
while (oondition) {
I/ statements
do-while loop: Executes statements at least once, then repeats while the
condition is true.
do {
l statements
}while (oondition);
Jump Statements in C:
Ans 6break: Exits the loop or switch.
continve: Skips the rest of the loop and jumpc to the next iteration.
return: Exits a function.
Selection vs Iteration Statemente:
Ams? Selection statements Gf else, switeh) make decisions based on
conditions.
Iteration statements (for, while, do-while) repeat a bleck of code.
goto Statement in C:
The goto statement in C allows junping to a labeled statement within the
same function.
Ans &goto label,
int numInt = 10;
double numDovble = doubfe)numIat;
Functions and Formal vs Actual Paramefers:
Functions in C are used to group code into modlar units. Formal
parameters are in the function definifion, while actual parameters are
passed during the funetion cal
Ans 10 unctions increases the code reusability and readability It
decreases the nuber of lines
void add(int a, int b) {I7 formal parameters
/function body
I/function call with actual parameters
add(s, 3):
11. Differentiate between structure and array.
12. What is a Ternary oper ator (?:) or conditional operator in C? Explai
its usage with an example.
13. Differentiate between exit cOntrolled and entry controlled loop.
19. Whycall by reference method is preferred over call by value method?
15. Define Pointer Variable.
16. What are Pointerc? What are the benefits of using pointers? Explain
with an example.
17. State the use of break and continve statements along with an example
18. Differentiate between Pre and Post increment operator with suitable
exanple.
19. Define the term ) identifier (i) token.
20. Why functions are needed ? Differentiate betueen local and Global
variable using suitable example.
21. When is a switch statement better than multiple if statemente?
22. What is Recursion?
23. What is dyaamic memory allocation? Write and explain the different
dynamic memory allocation functions in C.
24. What is a file? Explain how the file open and file close functions
handled in C?
25. Differentiate the folowing functions using exmples
Plz answer these questions and be accurate
Ans 11Structure vs. Array:
A structure is a user-defined data type that groups diferent types of data
under a single hame.
under a single hame.
An array is a collection of similar data elements stored in contigvous
memory locations.
Ans 12 Ternary Operator in C:
The ternary operafor ?: is a shorthand for an if-else statement.
Syntax: condition ? exprecsion_iftrue : expression iffalse.
Example: int result =(x>y)?x:y; assigns the larger value of xand yto
the variable result.
Ans 13Exit Controlled vs. Entry Controlled Coop:
Exit controlled loops check the oondition after exeouting the loop body.
Exanple: do-while.
Entry contralled loops check the condition before entering the loop body.
Example: while and for.
Ans 14 Call by Refer ence vs. Call by Value:
Call by reference passes the address of variables to functions, allowing
modifications.
Call by value passes actual values, initing changes to the function seope.
Ans 15Pointer Variable:
A
pointer variable stores the memory address of another variable.
Ans 16 Pointers in C
Pointers are variables that hold memory addresses.
Benefits include dynamic memory allocation and efficient manipulation of
data structures.
Example: int "ptr; int x = 10; tr = Box
Ans 17Break and Continve Statemente:
break: Exits the loop or switch stateent.
Ans 16Pointers in C:
Pointers are variables that hold memory addresses.
Benefits inolude dynamic memory allocation and efficient manipulation of
data structures.
Example: int ptr; int x= 10; ptr - &x
Ans 17Break and Continve Statfements:
break: Exits the loop or suitch statement.
continue: Skips the rest of the loop and jumps to the next iteration.
Example:
for (int i = 0; i< 10; i++) {
if(i == 5){
break:I/ exits loop at i=5
if 6%2 == 0) {
continve;/ skips even numbers
Ilcode
Ans 18Pre vs. Post Inerement Operator:
++i (pre-increment): Incremente the vave before ite vse.
it+ (post-increment): Uses the current valve and then increments.
Example:
int i = 5;
int a = ++i; /a=6, i=6 (pre-incr ement)
int b = itt; //b=6, i=? (post-increment)
Ans 19Identifier and Token:
Identifier: Name given to elementc in a programn (e.g., variable names).
qlobal variables are declared ovtside functions and have broader scope.
Example:
int globalVar = 10; Il global variable
void exampleFunetion 0{
int locallar = 5; /local variable
/ code vsing globalar and localVar
Ans 21Suitch Statement vs. Multiple if Statementr:
Use a suiteh statement when multiple conditions are based on the value of
a single expression, enhancing code readability.
Ans 22 Recursion:
Recurcion ist a programiming concept where a function calls itself.
Dynamie Memory Alooation in C:
Functions: malloc, calloe, realloc, free.
Example:
global variables are declared ovtside functions and have broader scope.
Example:
int globallar = 10:I/global variable
void exanpleFunction 0{
int locallar = 5; /local variabe
Il eode using globallar and locallar
Ans 21Suwitch Statement ve. Multiple if Statements:
Use a switch statenment when hultiple conditions are based on the value
a single exprescion, enhaneing code readabity.
Ans 22 Recursion:
Recursion is a progranming concept where a function calls itself
Dynamic Memory Allocation in C:
Functions: malloc, callec, realloe, free.
Example:
int 'arr = (int)nalloe(s sizeof(int)):
Il code using arr
free(arr):
Ans24 File in C:
Afle is a collec tion of data stored on secondarystorage.
File handing funetions: fopen, felose.