Sample Lab Report of C
Sample Lab Report of C
Lab-report on c-programming
(COMPUTER SCIENCE)
STUDENT ID NUMBER:-
REGISTRATION NUMBER:-
STUDENT’S EMAIL:-
KATHMANDU, NEPAL
2023
TRINITY INTERNATIONAL SS & COLLEGE
Lab sheet #1
(Input and output functions)
Lab date:-
Submission date:-
Page 1
Table of Contents
Objectives:-............................................................................................1
Theory ....................................................................................................3
Data Input and Output functions in C ...................................................3
Algorithm to find area of rectangle: ......................................................5
Flowchart to find area of rectangle: ......................................................5
Program Code to find area of rectangle: ...............................................6
Sample Output : .....................................................................................7
Conclusion:- ..........................................................................................8
Page 2
Theory
Data Input and Output functions in C
Page 3
represented as \n and gets generated when you press
the enter key. gets assigns the read string to the variable that is passed
as its parameters. gets assigns NULL when an error occurs.
The standard library function puts sends the passed string to stdout.
After the output, puts sends out a carriage return and a line
feed character. This takes the cursor to the next line automatically.
scanf()
The scanf function is used to read formatted input data. The format in
which input data is to be provided is specified by the scanf function
itself as it's first parameter. The scanf function is written as -
scanf(<control string>, &address1, &address2, . . . , &address_n);
Here, the first parameter <control string> contains a list of format
specifiers indicating the format and type of data to be read. The
remaining parameters - &address1, &address2, ..., &addressn are
addresses of the variables where the read data will be
stored. scanf reads the input data as per the format specifiers and
stores them (i.e., assigns them) to the corresponding addresses.
An & is pre-fixed to the variable name to denote its address.
Note that there must be the same number of format specifiers and
addresses as there are input data. For instance, in the following
example:
scanf("%d %f",&x,&y);
Page 4
Question 1 :
Page 5
Program Code to find area of rectangle:
#include<stdio.h>
// C program to find araa of rectangle
main()
{
printf("\n Program written by Student Name \n");
int l,b,area;
printf(" Enter length and breadth : ");
scanf("%d%d",&l,&b);
area=l*b;
printf(" Area of rectanlge is %d",area);
}
Page 6
Sample Output :
Question 2 :
algorithm:
flowchart
Program code:
sample output:
Question 3:
algorithm:
flowchart
Program code:
sample output:
-------------
and follow this to all questions given in the lab work list
Page 7
Conclusion:-
It was a wonderful time in the lab and classroom while
learning. The outcome of the learning is great and is very
similar to the prediction made in the beginning. We learned
about input and output functions in detail. It helped us a lot in
our programming. We came to know its syntax, semantic with
example. I hope that this will help us in future in my project
work. At last I would like to thank my class subject teacher
for his support and cooperation.
Page 8