ASSIGNMENT #02
ASSIGNMENT #02
ASSIGNMENT #02
ROLL# = 20BSCS-036
DATE= 30-4-2021
DEPARTMENT= BS(CS)
-------------------------------------------------------------------------------------------------------------------
other types of data types are (Float (float a;) ("%f",a)), (Double (double a;) ("%l",a)), (Character (char
a;) ("%c",a)), (String (char a; "OR" char a[10];) ("%c",a)).
eg;
(For New line, " ¥n "), ( For Tab, " ¥t "), (For Backspace, " ¥b "), (For Return, " ¥r "), (For Backslash," ¥¥ "),
(For Single Qautaion mark, " ¥' "), (For double Qautaion mark, " ¥" ").
3. PREPROCESSOR DIRECTIVES:-
Preprocessor directives also known as library in the
program it helps the program to read the procedure that how to perform the task.
RELATIONAL OPERATORS: Relational operators are the Relational operations which are used to
check the condition whether it is true or false, to check that is it greater or lesser,e.t.c and are listed
below.
== checks that the both operands are equal or not (a==b) is not true
if yes then condition becomes true
!= checks that the both operands are equal or not (a!=b) is true
if the values are not equal then conditin is true
> checks that the value of left operand is greater (a>b) is not true then
the value of right operand then the condition becomes true
< checks that the value of left operand is less then (a<b) is true
the value of the right operand then the condition
becomes true
>= checks that the value of left operand is greater (a>=b) is not true
then or equal to the value of right operand then
the condition becomes true
<= checks that the value of left operand is less (a>=b) is true
then or equal to the value of right operand then
the condition becomes true
LOGICAL OPERATORS:
&& called logical AND operator, if both operands are (a&&b) is false
non-zero, then condition becomes true.
! called logical NOT operator. use to reverse the logical !(a&&b) is true
state of its operand, if a condition is true then the
logical NOT operator will makes it false.
5. SIMPLE IF, IF-ELSE & ELSE-IF STATEMENTS:-
SIMPLE IF STATEMENT: An if statement consists of a boolean expression followed by one or more
statements.
IF-ELSE STATEMENT: An if-else statement can be followed by an optional else statement, which
executes when the boolean expression is false.
ELSE-IF STATEMENT: An if-else statement can be followed by an optional else if.......else statement,
which is very useful to test various conditions.
6. SWITCH STATEMENT:-
A switch statement allows a variable to be tested for equality against a
list of values. Each value is called a case, and the variable being switched on is checked for each switch
case.
7. FOR LOOP IN C :-
A for loop is a repeatation control structure that allows you to eecute a
specific number of times.
8. WHILE LOOP IN C :-
A while loop in C programming language repeatedly executes a target
statement as long as a given condition is true.
9. DO....WHILE LOOP IN C :-
Unlike for and while loops, which test the loop condition at the top of
the loop, the do....while loop in C programming language checks its condition at the bottom of the
loop.
A do...while loop is simillar to a while loop, except that a do...while loop is guaranteed to execute at
least one time.
10. ARRAY (Declearing, Initializing, Accessing) :-
An Array is used to store a collection of data, but it is often more useful
to think of an array as a collection of variables of the same type.
DECLARATION OF AN ARRAY:
Data_type of array_name[size];
int a[10];
INITIALIZATION OF AN ARRAY:
int a[5]={20,30,40,50,60}
printf("%d",a[0]);
OR
for(i=0;i<5;i++)
printf("%d",a[i]);
}
THE END