C Program 1 To 6
C Program 1 To 6
Uses:
To complete the above experiment, the steps of using devices are as follows:
Activities:
File Save :
1. When the compile button is clicked from the compile menu, the file is
converted to machine code from source code. If there are any errors, the
errors are also shown. After necessary correction file is saved again.
2. To run the program ctrl+F9 button is pressed simultaneously from the
keyboard.
Explanation:
The statements used in the above program are explained below-
printf(“expression”)
scanf(“input format”, &variable name)
printf(“Expression with output format”, variable name)
expression = What you want to see on the monitor should be written here.
input/output format =
%d = The data type of the variable will be “int”
%f = The data type of the variable will be “float”
%c = The data type of the variable will be “char”
Observation:
Sum = 82
Average = 41
Flowchart:
Experiment No: 2
Name of the experiment: To write a C program to convert Celsius
scale temperature to Fahrenheit scale.
Theory:
Any temperature can be easily converted from one scale to another by using
formulas. This task can be easily done through computer programming.
Uses of Devices:
Hardware: A computer
Software:
o Operating system – Windows 7
o Programming language
o Turbo C++ Compiler
Uses:
To complete the above experiment, the steps of using devices are as follows:
Activities:
File Save:
Explanation:
The statements used in the above program are explained below-
printf(“expression”)
scanf(“input format”, &variable name)
printf(“Expression with output format”, variable name)
expression = What you want to see on the monitor should be written here.
input/output format =
%d = The data type of the variable will be “int”
%f = The data type of the variable will be “float”
%c = The data type of the variable will be “char”
Observation:
When the experiment is completed, if we provide input 100 as Celsius scale
temperature, the following result will be shown.:
Area = ƒ𝑠 ∗ (𝑠 − 𝑎) ∗ (𝑠 − 𝑏) ∗ (𝑠 − 𝑐)
(a+b+c)
Where s =
2
a
Uses of Devices:
Hardware: A computer
Software:
o Operating system – Windows 7
o Programming language
o Turbo C++ Compiler
Uses:
To complete the above experiment, the steps of using devices are as follows:
File Save:
1. When the compile button is clicked from the compile menu, the file is
converted to machine code from source code. If there are any errors, the
errors are also shown. After necessary correction file is saved again.
2. To run the program ctrl+F9 button is pressed simultaneously from the
keyboard.
Explanation:
The statements used in the above program are explained below-
printf(“expression”)
scanf(“input format”, &variable name)
printf(“Expression with output format”, variable name)
expression = What you want to see on the monitor should be written here.
input/output format =
%d = The data type of the variable will be “int”
%.3f = Will display up to 3 digit values after the decimal point.
%c = The data type of the variable will be “char”
Observation:
When the experiment is done, inputting 2, 4, 3, and 5 for each side length
from the keyboard will give the following result:
Flowchart:
Experiment No: 4
Name of the experiment: To write a C program to find the area of a
circle when the radius is given.
Theory:
By taking the radius, the area of the circle needs to be determined. The required
formula is given below:
Uses of Devices:
Hardware: A computer
Software:
o Operating system – Windows 7
o Programming language
o Turbo C++ Compiler
Uses:
To complete the above experiment, the steps of using devices are as follows:
Program:
File Save:
Explanation:
The statements used in the above program are explained below-
printf(“expression”)
scanf(“input format”, &variable name)
printf(“Expression with output format”, variable name)
define = Global variable
expression = What you want to see on the monitor should be written here.
input/output format =
%d = The data type of the variable will be “int”
%f = The data type of the variable will be “float”
%c = The data type of the variable will be “char”
Observation:
Flowchart:
Experiment No: 5
Name of the experiment: To write a C program to check whether the
number is even or odd.
Theory:
To determine whether a number is even or odd first, the number is divided by 2 to
find the remainder. If the remainder is equal to zero then the number will be an
even number otherwise it will be an odd number.
Uses of Devices:
Hardware: A computer
Software:
o Operating system – Windows 7
o Programming language
o Turbo C++ Compiler
Uses:
To complete the test using the apparatus, the following steps are followed –
1. At the beginning of the experiment, the electrical connection of the computer
is checked.
2. If the electrical connection is ok, the computer is turned on by turning on the
computer's power switch.
3. It is checked whether the necessary programs are installed on the computer or
not.
4. The required program is launched to complete the experiment.
5. When the test is completed, the running programs are closed and the
computer is shut down according to the rules. For extra safety, the power is
disconnected by turning off the electrical switch.
Activities:
File Save :
1. When the compile button is clicked from the compile menu, the file is
converted to machine code from source code. If there are any errors, the
errors are also shown. After necessary correction file is saved again.
2. To run the program ctrl+F9 button is pressed simultaneously from the
keyboard.
Explanation:
The statements used in the above program are explained below-
printf(“expression”)
scanf(“input format”, &variable name)
printf(“Expression with output format”, variable name)
if-else statement is the extended form of if statement. If the expression
is true the statement_1 will be executed otherwise statement_2 will be
executed.
expression = What you want to see on the monitor should be written here.
input/output format =
%d = The data type of the variable will be “int”
%f = The data type of the variable will be “float”
%c = The data type of the variable will be “char”
Observation:
Uses:
To complete the test using the apparatus, the following steps are followed –
1. At the beginning of the experiment, the electrical connection of the computer
is checked.
2. If the electrical connection is ok, the computer is turned on by turning on the
computer's power switch.
3. It is checked whether the necessary programs are installed on the computer or
not.
4. The required program is launched to complete the experiment.
5. When the test is completed, the running programs are closed and the
computer is shut down according to the rules. For extra safety, the power is
disconnected by turning off the electrical switch.
Activities:
File Save :
1. When the compile button is clicked from the compile menu, the file is
converted to machine code from source code. If there are any errors, the
errors are also shown. After necessary correction file is saved again.
2. To run the program ctrl+F9 button is pressed simultaneously from the
keyboard.
Explanation:
The statements used in the above program are explained below-
printf(“expression”)
scanf(“input format”, &variable name)
printf(“Expression with output format”, variable name)
if-else statement is the extended form of if statement. If the expression
is true the statement_1 will be executed otherwise statement_2 will be
executed.
The structure is given below:
if(expression)
statement_1;
else statement_2;
expression = What you want to see on the monitor should be written here.
input/output format =
%d = The data type of the variable will be “int”
%f = The data type of the variable will be “float”
%c = The data type of the variable will be “char”
Observation: