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

To demonstrate and write a simple program using C++

Introduction
C-Free is an Integrated Development Environment (IDE) for C and C++ programming language. With
this environment you can edit, build, run, and debug your program freely, Dev-C++ is a free integrated
development environment (IDE) for programming in C/C++. Dev-C++ is developed by Bloodshed
software. Dev-C++ you can write Windows or console-based C/C++ programs easily, you can even
create installer for your application.

Objectives
In this lab software (DEV C++ and C Free) introduction has been discussed along with basic writing of
the program inside the compiler and its steps.

Outcomes
By the end of this experiment, student will have basic understanding of
How to open the C Free 5.0/Dev C++
Write and execute a simple program that print a simple statement.
Find and correct the errors.

Theory Overview
C++ is a statically-typed, free-form, (usually) compiled, multi-paradigm, intermediate-level general-
purpose middle-level programming language. Many of today’s operating systems, system drivers,
browsers and games use C++ as their core language. This makes C++ and its software like C Fee and
DEV C++ an excellent choice. Since it is an enhanced/extended version of C programming language,
C and C++ are often denoted together as C/C++.

Software / Hardware:
A PC system.
Visio 2013.

Procedure

Step 1
Open the working environment DEV C++ as shown in figure 29.1

Figure 29.1: working environment of DEV C++


Step 2

Create new Project as shown in figure 29.2


1
Figure 29.2: Project creation in DEV C++

Step 3
Name the project as shown in Figure 29.3

Figure 29.3: New project window of DEV C++

Step 4
Save the project as shown in Figure 29.4
2
Figure 29.4: Location of the saved C++ project

Step 5
Create new file as shown in Figure 29.5

Figure 29.5: Creation of new C++ source file

Step 6
Write a C code to print” Hello world” on the output screen as shown in Figure 29.6

Figure 29.6: Code snippet for “Hello World” program


Step 7
Save the file in your selected folder as shown in Figure 29.7

3
Figure 29.7: Location of the saved C++ source file

Step 8

Compile the program using key F9 and run the code using F10 as shown in figure 29.8

Figure 29.8: Compiling C++ code

Step 9
Show the Output on screen as shown in Figure 1.9

Figure 29.9: Compiled Output of “Hello World” program

4
Introduction to C Free software
Step1

Open the program C Free as shown in Figure 29.10

Figure 29.10: C-Free logo on startup

Step 2
C Free Working Environment as shown in Figure 29.11

Figure 29.11: Working Environment of C-Free

Step 3
Create the New Project as shown in Figure 29.12

Figure 29.12: New project window of C-Free

5
Step 4

Create a New file as shown in Figure 29.13

Figure 29.13: New file creation in C-Free

Step 5
Save the file test.cpp as shown in Figure 29.14

Figure 29.14: Naming and saving the C++ source file in C-Free

6
Step 6

Write a c program as shown in Figure 29.15

Figure 29.15: Test code snippet

Step 7
Run the program by click on run button or press F5 key as shown in Figure 2.6

Figure 29.15: Compiled output of test code snippet

LAB Exercise Programs

Program 1
Write a program to print your name on the output screen

7
#include <iostream>
/* this program is print your name on the output
screen */ using namespace std;
int main( )
{
cout<<"Shahid
Ali"<<endl; return 0;
}

Program 2
Write a program to calculate the sum of any two numbers on the output screen

#include
<iostream> using
namespace std; int
main( ) {
int a,b,sum;
a=2;
b=3;
sum=a+b;
cout<<"Sum
="<<sum<<endl; return 0;
}
Program 3
Write a program to multiply any two numbers and print the result on the output screen

#include
<iostream> using
namespace std; int
main( ) {
int a,b,mul;
a=2;
b=3;
mul=a*b;
cout<<"Multiply
="<<mul<<endl; return 0;
}

Review Questions

Question 1
Write down the syntax for declaration of variable
Question 2
Write a C++ program to compute area of a rectangle.

8
Question 3
Write a C++ program to compute area of a circle.
Question 4
A student appears in an examination consisting of total 3 subjects with each subject
having maximum marks of 100. The student’s roll number and obtained marks in each
subject is given as an input. Write a C++ program to compute the percentage of the
student and print it with his/her roll number.
Question 5
Write a program to add and multiply any three variables a,b,c and print the
result on the output screen.
Rubrics
Lab Performance

Sr. Performance Excellent Good Average Fair Poor


No. Indicator 5 4 3 2 1
1 Ability to Fully Has good Has average Has fair Has poor
Conduct understand the understanding of understanding of understanding understanding
Experiment lab instruments the lab instruments the lab instruments of the lab of the lab
including its including its including its instruments instruments
purpose and purpose but able to purpose and able to including its including its
quite able to conduct conduct experiment purpose and purpose and
conduct the experiment with with help and able to conduct unable to
entire some help from lab taking more than experiment with conduct
experiment with instructor one attempt help and taking experiment
negligible help more than three
from lab attempts
2 Data Analysis Always Most of the time Sometime Analyzes Analyzes and Analyzes and
instructor
and analyzes and Analyzes and and interprets data interprets data interprets data
Interpretation interprets data interprets data accurately, some of very poorly, incorrectly
correctly and correctly; most of the conclusion are most of the most of the
always draws the conclusion are correct; sometime conclusion are time; many
correct correct; compares able to compare the incorrect; Not conclusions
conclusions; theory against theory against able to compare are incorrect;
experimental experimental results the theory most of the
always
results and and calculates against time never
compares
calculates related related error experimental attempts to
theory against error most of the results and compare
experimental time. calculates theory against
results and related error experimental
calculates results.
related error.

Lab Report

Sr. Performance Excellent Good Average Fair Poor


No. Indicator 5 4 3 2 1
1 Material/ Procedure, Procedure, results Procedure, results, Procedure, The content is
Content results and and conclusions conclusions and results and very poor/
conclusions are are very well Graphs/ waveforms conclusions have meaningless.
very well written. Data have few mistakes. major mistakes.
written. presentation is not Data is not
Appropriate up to the mark. presented using
graphs/wavefor graphs/
ms are used to waveforms.
present the data.

9
2 Calculations All of the data Most of the data Some of data Most of the data All of the data
analyzed is very analyzed is analyzed is analyzed is analyzed is
accurate and accurate with many accurate having inaccurate based inaccurate
precise. logical and few logical and on illogical based on
Completely systematic systematic calculations illogical
logical and calculations calculations calculations.
systematic
calculations

Viva Voce
Sr. Performance Excellent Good Average Fair Poor
# Indicator 5 4 3 2 1
1 Responsivenes Responds well, Generally Generally Not much Non
s to quick and very Responsive and Responsive and Responsive and Responsive
Questions/ accurate all the accurate most of the accurate few times. accurate most of and inaccurate
Accuracy time. times. the times. all the times.
2 Level of Provide complete Provide complete Provide partially Provide very few Provide no
understanding and logical and logical answers correct and logical and illogical answer to the
of the learned answers based based upon accurate answers based upon answers to the questions
skill upon accurate technical content to minimum technical questions asked asked by
technical content the questions asked content to the by examiner. examiner.
to the questions by examiner with questions asked by
asked by few errors examiner
examiner

10

You might also like