Question and Answers
Question and Answers
11. What are the different data types in C? Explain with memory size.
int (2 or 4 bytes), float (4 bytes), double (8 bytes), char (1 byte), short (2 bytes), long (4 or 8
bytes depending on system).
13. Can variable names start with a number? Why or why not?
No, variable names cannot start with a number because it's against the syntax rules of C.
14. What is the difference between a local variable and a global variable?
Local variables are declared inside functions and accessible only within them. Global
variables are declared outside all functions and accessible throughout the program.
17. Can we use switch for float values? Why or why not?
No, switch only works with integer or character types. Float comparisons are not precise.
21. What is the difference between for, while, and do-while loops?
for: Loop with initialization, condition, and increment in one line.
while: Checks condition before execution.
do-while: Executes once before checking the condition.
23. Can we use break and continue inside loops? What do they do?
Yes. break exits the loop. continue skips the current iteration and moves to the next.
24. What is an infinite loop? How can you write one using each loop?
A loop that never ends.
for(;;) {}
while(1) {}
do {} while(1);