Lab 1
Lab 1
l
e
.
3.Save the file with .c extention.
4.Write your first code here and then click on “Build and Run” icon.
5.Output:
STRUCTURE OF „C‟ PROGRAM :
HEADER FILES
Header files are helping file of your C program which holds the definitions of various
functions and their associated variables that needs to be imported into your C program
with the help of pre-processor #include statement. All the header file have a '.h' an
extension that contains C function declaration and macro definitions. In other words, the
header files can be requested using the preprocessor directive #include. The default header
file that comes with the C compiler is the stdio.h.
Including a header file means that using the content of header file in your source program.
“#include<stdio.h>” is the basic header that must be added to a C program. Other headers
that can be needed are:
abs(),sqrt(),pow(),sin(),cos(),tan(),log(),ceil(),floor(),round() etc.
rand(),atof(),atoll(),atoi() etc.
https://en.cppreference.com/w/c/header
FORMAT SPECIFIER IN C:
LAB EXERCISE #1
Objective(s):
To be familiar with syntax and structure of C- programming. To learn
problem-solving techniques using C
Program: Write a Program to calculate and display the volume of a CUBE having its height
(h=10cm), width (w=12cm) and depth (8cm).
#include<stdio.h>
void main()
{
//start the program
int h,w,d,vol;
//variables declaration
h=10;w=12;d=8;
//assign value to variables
vol=h*w*d;
//calculation using mathematical formula
getch();
//end the main program
}
Output :
The Volume of the cube is: 960
SAMPLE PROGRAMS
(Students are to code the following programs in the lab and show the output to instructor/course
teacher)
Instructions
Programs List