0% found this document useful (0 votes)
6 views

Lab-Sheet - 1

The document is a lab sheet for C programming basics, outlining objectives, instructions for using a text editor or Code::Blocks IDE, and problems to solve. It includes steps for writing, compiling, and running a simple C program, as well as additional programming tasks. Students are required to submit a lab report detailing their work and any syntax errors encountered.

Uploaded by

mrrandom9867
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

Lab-Sheet - 1

The document is a lab sheet for C programming basics, outlining objectives, instructions for using a text editor or Code::Blocks IDE, and problems to solve. It includes steps for writing, compiling, and running a simple C program, as well as additional programming tasks. Students are required to submit a lab report detailing their work and any syntax errors encountered.

Uploaded by

mrrandom9867
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Lab Sheet -1: C Programming Basics Santa Basnet Lab Sheet -1: C Programming Basics Santa Basnet

C Language Basics d) Now you are ready to write your first program in C. Type the
following code:
1.1 Objectives
/* Hello World */
1. To get acquainted with the programming editor or the
#include <stdio.h>
Code::Blocks Integrated Development Environment (IDE).
int main() {
2. To learn the basics of program coding, compilation, run and
printf("Welcome to the programming world !\n");
the usage of printf() and scanf().
return(0);
Time-span: Two lab days (4 hrs)
}
1.2 Instruction:
e) To compile your program, use the following command in the
We prefer to use either a plain text editor or Code::Blocks1 IDE to terminal. (You might need to open another instance of
write the computer programs in C. You might have other options as terminal.)
well.
$gcc <your_program.c> -o your_program
1.2.1 Using a text editor: gedit
f) To run your program, use the following command in the
a) Create a folder where you want to place your C program terminal.
source, you can use mkdir <folder_name> command to do
$./your_program
so.

b) Open a terminal and go to your newly created folder using


1.2.2 Using the Code::Blocks IDE:
cd command.
a) Create a folder where you want to place your C program
c) Create your first C program source file with the following
source, you can use mkdir <folder_name> command to do
command.
so.
$gedit <your_program.c>
b) Find Code::Blocks IDE from the application explorer and
Note: <your_program.c> is the file name you want give to Open it.
your new program.

1 https://www.codeblocks.org/downloads/
Everest Engineering College Page 1|5 Everest Engineering College Page 2|5
Lab Sheet -1: C Programming Basics Santa Basnet Lab Sheet -1: C Programming Basics Santa Basnet

c) Go to File => New => File => C/C++ Source and give use of escape sequences, the escape sequences in C are “\
name <your_program.c>. n”, “\t”, “\\” etc.
d) Type the following code: b. Calculate the mass of air in an automobile tyre, using the
formula:
/* Hello World */
PV = 0.37m(T+460)
#include <stdio.h>
where P is the air pressure in the tyre (pounds per square
int main() {
inch), V is the volume (in cubic feet), m is the mass of air (in
printf("Welcome to the programming world !\n");
pounds), T is the temperature in Fahrenheit.
return(0);
Note: Algorithm and Flowchart needed.
}
c. Write a program that reads the name of the user and greets
him/her. Refer the following sample output.
e) Save your code with Save file option in file menu Or you
Enter your name: Ramesh
can use Ctrl + S shortcut to save your new changes in the
Hello Ramesh! Welcome to the world of programming.
source file.
f) To compile your program, select Compile current file Note: The students should make a list of syntax errors that may
option from the Build menu. It will show errors if you write occur while attempting the programming problems and mention
incorrect syntax or some warning in many cases. You can why each of those errors occurred.
press Shift + Ctrl + F9 for shortcut to compile the source
1.4 Format of the Lab Report
file.
You need to submit the report of the laboratory work after
g) To run your program: select Run from Build menu. It will
completion of each sheet. The report should have a cover page
display your program output. You can press Ctrl + F10 for
mentioning:
shortcut.
(i) Your name and Class Roll Number,
1.3 Problems
(ii) Lab sheet title and problem.
a. Use the printf() function for drawing (a) a house, (b) a tree
The body of the report should include the following components for
and (c) any figure from your imagination. Make appropriate
each problem.

Everest Engineering College Page 3|5 Everest Engineering College Page 4|5
Lab Sheet -1: C Programming Basics Santa Basnet

1. The question.
2. Flowchart and algorithm (only for the questions which
explicitly asks to give flowchart/algorithm).
3. Properly commented and well-structured source code.

The last section of the report should include the Discussion


of your learning outcome. The reports for the lab sheets 1, 2
and 3 should also include an appendix describing the syntax
errors you faced while attempting the problems.

Everest Engineering College Page 5|5

You might also like