0% found this document useful (0 votes)
14 views22 pages

C Program 1 To 6

The document outlines a series of experiments involving C programming, including calculating sums, averages, temperature conversions, area of triangles and circles, checking even or odd numbers, and identifying the largest number among three inputs. Each experiment includes a theoretical background, hardware and software requirements, step-by-step procedures for execution, and expected observations. The document serves as a practical guide for students learning programming concepts using Turbo C++ on a Windows 7 operating system.

Uploaded by

nakibanam249
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views22 pages

C Program 1 To 6

The document outlines a series of experiments involving C programming, including calculating sums, averages, temperature conversions, area of triangles and circles, checking even or odd numbers, and identifying the largest number among three inputs. Each experiment includes a theoretical background, hardware and software requirements, step-by-step procedures for execution, and expected observations. The document serves as a practical guide for students learning programming concepts using Turbo C++ on a Windows 7 operating system.

Uploaded by

nakibanam249
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 22

Experiment No: 1

Name of the experiment: To write a C program to find the sum


and average of 2 integers taken from the keyboard.
Theory:
The scanf() keyword is used to input data from the keyboard. The sum is obtained
by adding the inputted data. Dividing the sum by the total number, the average is
calculated.
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:

(1) At first one needs to check the electricity connection


(2) If the electricity connection is ok, then one needs to switch on the power
of the computer.
(3) To check whether the above mentioned software’s are installed or not.
(4) Necessary programs have to be started to complete the experiment.
(5) After completing the experiment all programs should be closed and
computer should be shut down and the electric connection has to be switched
off.

Activities:

To complete the test, work according to the procedure described below:


Double-click on the icon located on the desktop, open the complier and write the
following program code in the code building editor:
Program:

Write from your ICT Practical Book

File Save :

1. "Save As" option is selected from the File menu.


2. In the "Save File As" text box "Program 01" is written as the file name and
the ok button is clicked.

Run the program:

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:

When the experiment is completed, if we provide input 69 and 13 from the


keyboard, the following result will be shown:

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:

(1) At first one needs to check the electricity connection


(2) If the electricity connection is ok, then one needs to switch on the power
of the computer.
(3) To check whether the above mentioned software’s are installed or not.
(4) Necessary programs have to be started to complete the experiment.
(5) After completing the experiment all programs should be closed and
computer should be shut down and the electric connection has to be switched
off.

Activities:

To complete the test, work according to the procedure described below:


Double-click on the icon located on the desktop, open the complier and write the
following program code in the code building editor:
Program:

Write From your ICT Practical book

File Save:

1. "Save As" option is selected from the File menu.


2. In the "Save File As" text box "Program01" is written as the file name and
the ok button is clicked.

Run the program:


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:
When the experiment is completed, if we provide input 100 as Celsius scale
temperature, the following result will be shown.:

Fahrenheit Scale Temperature = 212.000000


Flowchart:
Experiment No: 3
Name of the experiment: To Write a C program to find the area of a
triangle from the length of three sides.
Theory:
When the length of three sides of a triangle is given, to find the area, the perimeter
of the triangle needs to be calculated first, then the area can be determined. The
required formula is given below:
a
b

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:

(1) At first one needs to check the electricity connection


(2) If the electricity connection is ok, then one needs to switch on the power of the
computer.
(3) To check whether the above mentioned software’s are installed or not.
(4) Necessary programs have to be started to complete the experiment.
(5) After completing the experiment all programs should be closed and computer
should be shut down and the electric connection has to be switched off.
Activities:

To complete the test, work according to the procedure described below:


Double-click on the icon located on the desktop, open the complier and write the
following program code in the code building editor.
Program:

Write from your ICT Practical book

File Save:

1. "Save As" option is selected from the File menu.


2. In the "Save File As" text box "Program01" is written as the file name and
the ok button is clicked.

Run the program:

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:

Area of triangle is: 3.800

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:

Area = Pie * radius


*radius

Radiu Here the value of Pi is


s
constant. Pi = 3.1416

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:

(1) At first one needs to check the electricity connection


(2) If the electricity connection is ok, then one needs to switch on the power of the
computer.
(3) To check whether the above mentioned software’s are installed or not.
(4) Necessary programs have to be started to complete the experiment.
(5) After completing the experiment all programs should be closed and computer
should be shut down and the electric connection has to be switched off.
Activities:

To complete the test, work according to the procedure described below:


Double-click on the icon located on the desktop, open the complier and write the
following program code in the code building editor:

Program:

Write from your ICT Practical Book

File Save:

1. "Save As" option is selected from the File menu.


2. In the "Save File As" text box "Program01" is written as the file name and
the ok button is clicked.

Run the program:


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)
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:

When the experiment is completed, if we provide input 5 as the radius of the


circle, the following result will be shown.
Area = 78.540001

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:

To complete the test, work according to the procedure described below:


Double-click on the icon located on the desktop, open the complier and write the
following program code in the code building editor:
Program:

Write from your ICT Practical Book

File Save :

1. "Save As" option is selected from the File menu.


2. In the "Save File As" text box "Program01" is written as the file name and
the ok button is clicked.

Run the program:

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:

When the experiment is completed, if we provide input 69 as input from the


keyboard, the following result will be shown.

You entered an odd


number and the
number is 69
Flowchart:
Experiment No: 6
Name of the experiment: To write a program to identify the largest
number among three numbers.
Theory:
To find the largest number out of three numbers, the numbers need to be compared
with each other. Following this procedure, the largest number can be determined.
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:

To complete the test, work according to the procedure described below:


Double-click on the icon located on the desktop, open the complier and write the
following program code in the code building editor:
Program:

Write from your ICT Practical Book

File Save :

1. "Save As" option is selected from the File menu.


2. In the "Save File As" text box "Program01" is written as the file name and
the ok button is clicked.

Run the program:

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:

When the experiment is completed, if we provide input 7 as 1st number, 13 as


2nd number and 13 as 3rd the keyboard, the following result will be shown:

The Largest number is = 69


Flowchart:

You might also like