C Lab Manual 1 To 3
C Lab Manual 1 To 3
C Lab Manual 1 To 3
LIST OF PRACTICALS :-
1. Programming exercises on executing and editing a C program.
15
Note :-
<stdio.h> stands of Standard Input Output.
‘printf’ is used for output operation.
‘scanf’ is used for input operation.
\n is used for start the new line.
Here we are taking the value of kilogram by the user, we can also predefine
the value of kilogram.
We can also use ‘int’ data type, in that case we can’t get or give the floating
values to the system.
If we use ‘int’ data type in that case we must have replace the ‘%f’ with the
‘%d’ to run the program successfully
PRACTICAL :-2
Theory :-
Naming a variable :-
A variable name can be of anything we want to call out variable. Yet there are
specific rules we must follow while naming a variable :
a = 18;
Code :-
#include<stdio.h>
int main ()
{
int a = 12.2221;
printf("Output = %d",a);
return 0;
}
Declaration :-
We can’t declare a variable without specifying its data type. The data type of a
variable depends on what we want to store in the variable and how much space we
want it to hold.
PRACTICAL :-3
Arithmetic Operators :-
Arithmetic operators are used to perform mathematical operations such as addition,
subtraction, etc.
Arithmetic operators :- +, -, *, /, %
Code :-
#include<stdio.h>
int main ()
{
int a = 5;
int b = 6;
printf("a + b = %d\n",a+b);
return 0;
}
Logical Operators :-
Logical operators are used for performing logical operations. Logical operators
work with Boolean expressions and return a Boolean value. Logical operators are
used with the conditional operators in loops and decision-making statements.
Relational Operators :-
Relational operators are used for the comparison between two or more numbers.
Same as Java, C has also six relational operators and their value is in Boolean i.e.
either True or False ( 1 or 0 ).
Code :-
#include<stdio.h>
int main ()
{
int a = 2;
int b = 2;
printf("a == b = %d\n",a==b);
return 0;
}