Вы находитесь на странице: 1из 7

Computer Lab Computer programming I

Full Marks: 50

Marks Sub-division like

1. Clean Lab sheet submission on time : 15


2. Regular viva after completion of each lab: 10
3. Lab full class Attendance: 5
4. Minor Project (maximum 4 persons in a group) : 20

Marks distribution in Project will be like:


Presentation: 3
Report: 7
Demo 3
Questionnaires 7

Note: Project Proposal should be submitted before 18th February. Project Report
format will be published after approval of Proposal.

Lab Report should contain following topics:

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.

A sample Lab Report is attached below in following pages.

Prepared by Om Prakash Mahato.


Computer Lab Computer programming I

Index

Name: Subject:
Roll No: Programme:

S.N. Title of Experiment Date of Experiment Remarks

Prepared by Om Prakash Mahato.


Computer Lab Computer programming I

NATIONAL COLLEGE OF ENGINEERING


Satdobato, Talchhikhel, Lalitpur

Lab Report on

Computer Programming I

Lab Report No. -------

Submitted To:

Department of Computer and Electronics

Submitted By: Checked By:

Name:

Roll No.:

Programme:

Date:

Prepared by Om Prakash Mahato.


Computer Lab Computer programming I

Experiment: 1

1. Title: Basic Input and Output.

2. Objective : After completion of this experiment, the students will able to

Create, compile and run simple C programs


Handle different data types in C
Perform arithmetic operations in C
Perform formatted input and output operations
Perform character input and output operations

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.

Prepared by Om Prakash Mahato.


Computer Lab Computer programming I

Formatted output function ,printf


printf() is used for displaying the output on the standard output device. The
general syntax of printf() is as follows:
prinf(control string,arg1,arg2..);
here, control sting consist of message to be displayed on the screen, Escape
sequence(like \n new line character) , format specifier (%d for interger argument), and
arguments (variables). printf always takes order for format specifier and argument
matching.
For example : printf(the area of rectangle is: %f\n perimeter of rectangle is:%f
,area, perimeter);
Output: the area of reactangle is: 123.123456
perimeter perimeter of rectangle is: 45.123456
Formatted output function ,scanf
Scanf() stands for scans format, because it scans the input for valid tokens
and parse them according to a specified format. The general syntax for scanf()
function is as follow:
scanf(control string,&arg1,&arg2,..);
here control string contains generally format specifier like %d for int type variable
and %f for float type variable.
For example:
Scanf(%d%f&length,&breath);
Here, inputs like 12 and 4.5 separated by space bar will be assigned into the variable
length and breath as soon as enter key is pressed. Semi colon (;) is always appends
in each statement for ending the statements.

4. Algorithm:

a. For a program finding area and perimeter of rectangle


1. Start.
2. Read length and breath
3. Find area and perimeter.
4. Display area and perimeter.

Prepared by Om Prakash Mahato.


Computer Lab Computer programming I

5. Flowchart:

a.

Start

Read length
and breath

Find area =length*


breath.

And perimeter
=2*(length+breath).

Read length
and breath

Stop.

Figure 5.a :Flowchart of finding area and perimeter of a rectangle.

Note: Make flowchart neat and clean with use of pencil and scale on the backside.

Prepared by Om Prakash Mahato.


Computer Lab Computer programming I

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

Prepared by Om Prakash Mahato.

Вам также может понравиться