5. Hello World in Detail :
● stdio.h is a header file
● #include is a preprocessor directive.
● int main() : where the program execution
begins.
● { and } symbols mark the beginning and end of
a block of code.
● return 0; terminates the main() function
6. Identifiers
● name given to entities such as variables,
functions.
● Example - int money ;
● int money;
Here, money is identifier.
● must be different from keywords
9. Rules for naming a variable
● can have letters , digits and underscore only.
● The first letter of a variable should be either a
letter or an underscore
11. Integer
● positive and negative values but no decimal
values. Eg : 0, -5, 10 .
● Int id ;
● Here, id is a variable of type integer.
● Int id,age;
12. Floating types
● can hold real numbers such as: 2.34, -9.382,
5.0 etc.
● float price; // 4 bytes size
● double price; // 8 bytes size
● Both are floating types.
13. Character types
● Keyword char is used for declaring such
variables.
● char test = 'h';
● test is a character variable.
● The value of test is 'h'.
● No string type in C . alternative = char array
● Eg: char num[ ] = “hello”
14. I/O in C programming
● Two commonly used functions are printf() and
scanf().
● Function scanf() reads input.
● Function printf() prints output.
15. Format specifiers and ampersand
● scanf("%d”,&a); for int , &a means the address
of variable a
● scanf("%f”,&a); for float
● Scanf(“%c”,&ch);
● Scanf(“%s”,&word);
● printf("%d is value of a",a);
16. Operators
● to perform tasks including arithmetic, conditional and bitwise
operations
● Types :
1. Arithmetic Operators
2. Increment and Decrement Operators
3. Assignment Operators
4. Relational Operators
5. Logical Operators
6. Others (Conditional,Bitwise and Special Operators)
18. Increment and decrement operators
● Increment ++ increases the value by 1
● Decrement -- decreases the value by 1
● Example :
int a=5;
a++ . value of a is now 6
● Similarly, for a-- , a is 4
19. ++ and -- operator as prefix and
postfix
● Postfix a++ → original value of a is returned
first then, a is incremented by 1.
● Prefix ++a → value of a is incremented by 1
then, it returns the value.
24. if and if else statement
1 . if (testExpression)
{
// statements
}
2 . if (testExpression) {
// codes inside the body of if
}
else {
// codes inside the body of else
}
26. Nested if...else statement
if (testExpression1)
{ // statements to be executed if testExpression1 is true
}
else if(testExpression2)
{ // to be executed if testExpression1 is false and testExpression2 is true
}
...
else
{ // statements to be executed if all test expressions are false
}
27. Loops
● are used to repeat a specific block of code.
● Types -
1 . for loop
2 . while loop
3 . do while loop
34. Break and continue statement
● Break→ terminates the loop
● Continue → skips some statement
● Syntax :
break;
continue;
35.
36. Switch case
switch (n)
{
case constant1:
// code to be executed if n is equal to constant1;
break;
case constant2:
// code to be executed if n is equal to constant2;
break;
. . .
default:
// code to be executed if n doesn't match any constant
}
37. Functions
● a block of code that performs a specific task.
● Two types of functions :
1 . User defined functions
2 . Standard library functions
38. Standard library functions
● built-in functions
● handle tasks such as mathematical
computations, I/O processing, etc.
● Example : printf() and scanf()