Q1) A) Who is the father of the C language?
ANS=> Dennis Ritchie
B) Which of the following is not a valid C Variable Name?
ANS=> a) int number;
b) float rate;
c) int variable_count;
d) int $main;
C) scanf() is a predefined function in______header file.
ANS=> a) stdlib.h
b) ctype.h
c) stdio.h
d) stdarg.h
D) The format identifier “%d” is used for _____ data type.
ANS=> a) char
b) int
c) float
d) double
E) The operator ++ is used for ________.
ANS=> a.) Value assignment
b.) Increment by 1
c.) Logical comparison
d.) Condition Checking
F) A C Programm is a combination of ___.
ANS=> A) Statements
B) Functions
C) Variables
D) All of the above
Q2) 1) what is variable?
ANS=> A variable is like a container which stores values. Each
variable in C has a specific type, which determines the size
and layout of the variable's memory.
• Rules for Naming Variables in C:
1. Start with a letter or underscore: A variable name must
begin with a letter
(a-z or A-Z) or an underscore (_). It cannot begin with a
number.
o Valid: int age; , float _height;
o Invalid: int 1age;
2. Use only letters, digits, and underscores: After the first
character, a variable name can include letters, digits (0-9), and
underscores.
o Valid: int my_var;, char name1;
o Invalid: int my-var;
3. No spaces: Variable names cannot contain spaces.
o Valid: int myVar;
o Invalid: int my Var;
4. Case-sensitive: Variable names in C are case-sensitive, meaning
myvar and MyVar would be treated as two different variables.
o int myVar;
o int MyVar;
5. Avoid using C keywords: Keywords (reserved words) like int, if,
while, return, for, etc., cannot be used as variable names.
Invalid: int int;, float return;
2) Explain the structure of C Programme.
ANS=>
Q3) explain if else ladder with example.
ANS=> An else if ladder is a control structure used in C (and
other programming languages) that allows you to check
multiple conditions sequentially. It helps in choosing among
multiple alternatives based on different conditions.
Syntax:
if (condition1)
statement1;
else if(condition2)
statement2;
else if(condition3)
statement 3;
else
default statement;
Q4) Explain for loop with example.
ANS=> A for loop enables us to perform 'n' numbers of steps
together in one line. In for loop, a loop variable is used to
control a loop.
Example:
#include <stdio.h>
int main() {
int i;
for (i = 1; i < 11; ++i) {
printf("%d ", i);
}
return 0;
}