1 Lab PF

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 9

EXPERIMENT NO:01

TITLE: INTRODUCTION TO C (INSTALLATION OF AN IDE ON PC AND


A SIMPLE PROGRAM COMPILATION)
1.1 OBJECTIVE:
The purpose of this course is to introduce to students to the field of programming using C
language. The students will be able to enhance their analyzing and problem-solving skills and
use the same for writing programs in C.

1.2 PURPOSE:
• In school, students use computers for tasks such as writing papers, searching for articles,
sending email, and participating in online classes.
• At work, people use computers to analyze data, make presentations, communicate with
customers and coworkers, control machines in manufacturing facilities, and do many other
things.
• At home, people use computers for tasks such as paying bills, shopping online,
communicating with friends and family, and playing computer games.
• The uses of computers are almost limitless in our everyday lives. Computers can do such
a wide variety of things because they can be programmed.

1.3 TOOL:
Code::Blocks is an open-source, cross-platform (Windows, Linux, MacOS), and free
C/C++ IDE. It supports many compilers, such as GNU GCC (MinGW and Cygwin) and MS
Visual C++. It supports interactive debugging (via GNU GDB or MS CDB). Code::Blocks is
surprisingly versatile. The mother site of Code::Blocks is ww.codeblocks.org.
1.4 INSTALLATION:
1.5 GETTING STARTED WITH C:
A program is a set of instructions that a computer follows to perform a task.
There is a close analogy between learning English and learning C language.
1.5.1 DATA TYPES:
o Integer type:

Type Storage size Value range

char 1 byte -128 to 127 or 0 to 255

-32,768 to 32,767 or -2,147,483,648 to


int 2 or 4 bytes
2,147,483,647

short 2 bytes -32,768 to 32,767

long 4 bytes -2,147,483,648 to 2,147,483,647

o Floating point types:

Type Storage size Precision

Float 4 byte 6 decimal places

Double 8 byte 15 decimal places

long double 10 byte 19 decimal places


1.5.2 Libraries: Libraries:
• STDIO.H is a file which contain declaration
#include <stdio.h> of many functions which required to get input
from input devices and show output on output
screen of C Program.
• It is the header of the general purpose
#include <stdlib> standard library of C programming language
& includes functions involving memory
allocation, process control, conversions and
#include <math.h> others.
• Used for mathematical functions

int main() Main:


{ It is user defined function, because function
body is given by the user, what you will do with
main function if we won’t write anything inside
return 0; main function. compiler enters from here and
} also exit from here.

1.5.3 Output:
printf( ) is used for output and display.
Syntax:
Printf ( "<format string>", <list of variables> ) ;

<format string> can contain:


%f for printing real values
%d for printing integer values
%c for printing character values

1.5.4 Input:
scanf( ) is used for input.
Syntax:
scanf ( "<format string>", <&list of variables> ) ;
1.6 IN LAB TASKS:
Task 1:
Write a program to print your name and class.
(******Neelum Rasheed*******)
(****Electrical Engineering****)

Task 2:
Write a program that input two values and output the sum of these values.

1.7 POST LAB TASK:


Task 1:
Write a Program that print this
@@@@@@@@@
@@@@@@@@@
***Your Name***
@@@@@@@@@
@@@@@@@@@

Task 2: Write a program that calculate the area of Triangle and Rectangle by taking the values
length and width as an input, where formulas are given below.
area of triangle = length ∗ width
area of rectangle = 2(length + width)

You might also like