TRIBHUVAN UNIVERSITY
DEPARTMENT OF HUMANITIES AND SOCIAL SCIENCE
Bachelor of Computer Application
PRITHVI NARAYAN CAMPUS
Pokhara-1, Kaski
Lab Report on
Lab Report On C Programming
Submitted To :
Gyaneshwor Dhungana
Department of BCA
Submitted By:
Kumar Wagle
BCA , Second Semester
Roll no: 08
2079
LAB: 1
OBJECTIVE: TO PERFORM SIMPLE PROGRAMMING USING INPUT /
OUTPUT IN C LANGUAGE.
THEORY: C is the most powerful programming language developed in
1972 at Bell Lab by Dennis Ritchier.
It is function oriented language. It is portable. It has some feature of high
level language and some features of high level language and some
features of low level language. So, it is sometimes called mid-level
language.
It is used to perform the most common operations like calculations,
updation, etc. Some of the library functions are printf, scanf, sqrt, etc.
Printf() : It is used to print any types of messages
like Character, Number, etc.
Scanf() :It is used to take input from the user.
LAB: 1
DEMONSTRATION
PROGRAM No 1 : WRITE A PROGRAM TO INPUT LENGTH , BREADTH AND
DISPLAY IF IT SQUARE OR RECTANGLE.
Source code:
OUTPUT:
LAB: 1
PROGRAM No 2 : WRITE A PROGRAM TO DISPLAY DAYS (1-7) ON THE
BASIS OF NUMBER GIVEN BY USER.
Source code:
OUTPUT:
LAB: 1
PROGRAM No 3 : WAP TO INPUT AMOUNT &DISPLAY THE DISCOUNT
10% RECEIVED WHEN AMOUNT IS MORE THAN 5000 OTHERWISE
RECEIVED 5% DISCOUNT.ALSO DISPLAY THE TOTAL AMOUNT AFTER
DISCOUNT APPLIED.
Source code:
OUTPUT:
LAB: 1
PROGRAM No 4 : WRITE A PROGRAM TO INPUT A NUMBER & DISPLAY
THE LAST NUMBER.
Source code:
OUTPUT:
LAB: 1
PROGRAM No 5: WRITE A PROGRAM TO INPUT AN NUMBER & DISPLAY
IT IS NEGATIVE OR POSITIVE .
Source code:
OUTPUT:
LAB: 1
PROGRAM No 6: WRITE A PROGRAM TO INPUT AN NUMBER AND
DISPLAY IF IT MULTIPLE OF 5.
Source code:
OUTPUT:
LAB: 1
PROGRAM No 7: WRITE A PROGRAM TO DISPLAY THE GREATEST OF
THREE INTEGER .
Source code:
OUTPUT:
LAB: 1
PROGRAM No 8: WRITE A PROGRAM TO INPUT AN INTEGER & DISPLAY IT
IS EVEN OR NOT.
Source code:
OUTPUT:
CONCLUSION:
Hence, from the above experiment we are able to
understand & use of various library function &method to processed input
output step in C programming language.
LAB: 2
OBJECTIVE: TO WRITE THE C PROGRAM TO IMPLEMENT THE GIVEN
FORMULAE.
THEORY: C is high level general purpose and structure progrmming
language . It used compiler to change source code into machine code.
To objective of writing a c program to implement a given formula is to
create a program that can calculate the result of the formula using input
values provide the user or from a file, and then output the result to the
user or from a file, and then output the result to the user or from a file.
This can be useful in a variety of situation, such as in scientific or
engineering calculations, financial modeling or data analysis.
LAB: 2
DEMONSTRATION
PROGRAM No 1 :WRITE A PROGRAM TO DISPLAY THE SIMPLE INTEREST
I=PTR/100.
Source code:
OUTPUT:
LAB: 2
PROGRAM No 2:WRITE A PROGRAM TO CONVERT THE INPUT LENGTH
FROM CM TO KM,M AND CM.[KM=KILOMETER, M=METER AND
CM=CENTIMETER]
Source code:
OUTPUT:
LAB: 2
PROGRAM No 3 :WRITE A PROGRAM TO CONVERT THE INPUT RRUPEES
TO DOLLAR. [$1=Rs110.5]
Source code:
OUTPUT:
LAB: 2
PROGRAM No 4 : WRITE A PROGRAM TO CONVERT THE INPUT SECOND
TO HOUR MINUTE AND SECOND.
Source code:
OUTPUT:
LAB: 2
PROGRAM No 5 : WRITE A PROGRAM TO FIND THE AREA AND
CIRCUMFERENCE OF A CIRCLE.[A=pi*r^2&C=2*pi*r]
Source code:
OUTPUT:
LAB: 2
PROGRAM No 6 : WRITE A PROGRAM to FIND THE COMPOUND
INTEREST.
Source code:
OUTPUT:
CONCLUSION:
Hence, from this experiment we are able use the arithmetic operators,
perform arithmetic operations and implement different formulas in C
programming language.
LAB=3
OBJECTIVE: TO WRITE A C PROGRAM USING DIFFERENT
ESCAPE SEQUENCE.
Theory
An escape is a non-printing character used in C. It is a character
combination consisting of a backslash (\) followed by a letter or a digit.
Some of the escape characters are mentioned below:
Horizontal tab \t Insert a tab in the text at this point
New line \n Insert a newline in the text at this
point
Vertical tab \v Insert more space in the text at this
point
Double quote \” Insert double quote character in the
text at this point
Single quote \’ Insert single quote character in the
text at this point
Back Slash \\ Insert a backslash character in the
text at this point
LAB=3
DEMONSTRATION
PROGRAM No 6 : Write a program to display a message using various
escape character.
Source Code:
OUTPUT:
CONCLUSION:
Hence, from the above experiment we are able to use understand and use
escape character in program.