C Programming Lab Manual by Om Prakash Mahato
C Programming Lab Manual by Om Prakash Mahato
Full Marks: 50
Note: Project Proposal should be submitted before 18th February. Project Report
format will be published after approval of Proposal.
Title
Objective
Basic theory
Algorithm
Flowchart (always left side of the A4 size paper.)
Source code
Output
Discussion
Conclusion
Lab Report should submitted individually with Cover Page and one common Index
Page for all lab sheets in an individual file.
Index
Name: Subject:
Roll No: Programme:
Lab Report on
Computer Programming I
Submitted To:
Name:
Roll No.:
Programme:
Date:
Experiment: 1
3. Basic Theory:
#include<stdio.h>
#include<conio.h>
Any instructions that starts with # (pre-processor operator) take up a whole line, and
finish at the end of line which line is called pre-processor directive. Files ending with
.h are what known as header files, provided with each compiler and cover a range of
area such as string handling, mathematical conversions, printing and reading of
variables etc. stdio.h means standard in/out which means standard way of getting
data to and from input and output devices. In our case we wish to take in data from
keyboard (a standard input device) and put data on to the screen or console (a
standard output device.)
Conio.h means console in/out which means way of getting data to and from the
console device (which uses the keyboard and screen). Here , stdio.h is more
generalized, and can be used to read/write data from to a disk file for permanent
storage of data, write data out to a printing device, and so on. The conio.h library just
contains that deal specially with the console (keyword and black pop-up screen).
Printf , scanf etc functions are defined in stdio.h header file whereas getch(), clrscr()
functions are defined in conio.h header file.
Another use of pre-processor operator is to define the variable globally like
#define PI 3.1416
this global variable definition always comes before main function where a variable PI
is assigned by value of 3.1416.
Any C program always starts with at most one main() function.
void main()
{
Statements;
}
Here, void is return type of the function definition which returns nothing. { indicates
Start of main function and } indicates the end of main function.
4. Algorithm:
5. Flowchart:
a.
Start
Read length
and breath
And perimeter
=2*(length+breath).
Read length
and breath
Stop.
Note: Make flowchart neat and clean with use of pencil and scale on the backside.
6. Source Code:
a. For a program to find area and perimeter of a rectangle:
/* A program to find area and perimeter of a rectangle */
#include<stdio.h>
#include<conio.h>
void main()
{
int length ,breath, area, perimeter;
printf(enter the length and breath of rectangle);
scanf(%d%d,&length,breath);
area=length*breath;
perimeter=2*(length+breath);
printf(The area is:%d \n and The perimeter is:%d ,area,perimeter);
getch();
}
7. Output
a.
8. Discussion:
Discuss the following points
1. Process followed to perform the experiment.
2. Use of proper data types with their specifier in input and output
functions.
3. Errors what you got in this experiment with their debugs technique.
Note: write what did you understand doing this experiment but,
do not write anothers understanding i.e. do not copy the others
report.
9. Conclusion:
Hence, after completion of this experiment, we were able to
i) handle different data types with corresponding format
specifications.
ii) use the formatted input and output functions for taking input from
the standard input device (keyboard) and display the result on
standard output device (black pop-up screen).