Sunteți pe pagina 1din 31

Programming Fundamentals

LABORATORAY MANUAL

Name:…………………………

Roll No. : ……………………..

SEMESTER-

LAB ENGINEER:

Engr. HASNAIN AHMAD


Contents
Introduction to dev c++................................................................................................................................. 3
Installation ........................................................................................................................................... 3
Support for C++11 .............................................................................................................................. 3
Compiling console applications.......................................................................................................... 4
LAB #1 ......................................................................................................................................................... 6
Program Check Even/Odd using If, Else statement .............................................................................. 6
LAB #2 ......................................................................................................................................................... 8
Program To find the Grades by using If, Else Statement ...................................................................... 8
LAB#3 ........................................................................................................................................................ 10
Program To Find Average by Arithmetic Operators........................................................................... 10
LAB#4 ........................................................................................................................................................ 12
Program To find Percentage by Arithmetic Operators ....................................................................... 12
LAB#5 ........................................................................................................................................................ 14
Program To Find Greater Number ...................................................................................................... 14
LAB #6 ....................................................................................................................................................... 16
Program to Use multiple operations to make a Calculator Using Switch Statements ........................ 16
LAB #7 ....................................................................................................................................................... 18
Program to Check the Alphabet if “It is Vowel?” by Using Logical Operators ................................. 18
LAB #8 ....................................................................................................................................................... 20
Program To find Factorial of Any Number Using Loop Statement .................................................... 20
LAB #9 ....................................................................................................................................................... 22
Program To Sum, Subtract, Multiply and divide numbers using if statement. ................................... 22
LAB #10 ..................................................................................................................................................... 24
Program to Add two numbers Using Functions. ................................................................................. 24
LAB #11 ..................................................................................................................................................... 26
Program to Draw Pascal's triangle ...................................................................................................... 26
LAB #12 ..................................................................................................................................................... 28
Program to display Floyd's Triangle. .................................................................................................. 28
LAB #13 ..................................................................................................................................................... 30
Program of Passing by reference using pointers to Swap Numbers. .................................................. 30

ENGR HASNAIN AHMAD 2


Introduction to dev c++
Installation
Run the downloaded executable file, and follow its instructions. The default options are fine.

Support for C++11


By default, support for the most recent version of C++ is not enabled. It shall be explicitly
enabled by going to:

Tools -> Compiler Options

Here, select the "Settings" tab, and within it, the "Code Generation" tab. There, in "Language
standard (-std)" select "ISO C++ 11":

ENGR HASNAIN AHMAD 3


Ok that. You are now ready to compile C++11!

Compiling console applications


To compile and run simple console applications such as those used as examples in these tutorials
it is enough with opening the file with Dev-C++ and hit F11.

As an example, try:

File -> New -> Source File (or Ctrl+N)

There, write the following:


1 #include <iostream> Edit & Run
2 int main()

ENGR HASNAIN AHMAD 4


3 {
4 Auto x = R"(Hello world!)";
5 std::cout<< x;
6 }

Then:

File -> Save As... (or Ctrl+Alt+S)

And save it with some file name with a .cpp extension, such as example.cpp.

Now, hitting F11 should compile and run the program.

If you get an error on the type of x, the compiler does not understand the new meaning given
to auto since C++11. Please, make sure you downloaded the latest version as linked above, and
that you enabled the compiler options to compile C++11 as described above.

ENGR HASNAIN AHMAD 5


LAB #1
Apparatus
Dev C++, Operating System, Computer.

Objective
Program Check Even/Odd using If, Else statement
Code

ENGR HASNAIN AHMAD 6


Output

Precautions

ENGR HASNAIN AHMAD 7


LAB #2
Apparatus
Dev C++, Operating System, Computer.

Objective
Program To find the Grades by using If, Else Statement
Code

ENGR HASNAIN AHMAD 8


Output

Precautions

ENGR HASNAIN AHMAD 9


LAB#3
Apparatus
DEV C++,Operating system,Computer

Objective
Program To Find Average by Arithmetic Operators
Code

ENGR HASNAIN AHMAD 10


Output

Precautions

ENGR HASNAIN AHMAD 11


LAB#4
Apparatus
DEV C++, Operating system, Computer

Objective
Program To find Percentage by Arithmetic Operators
Code

ENGR HASNAIN AHMAD 12


Output

Precautions

ENGR HASNAIN AHMAD 13


LAB#5
Apparatus
DEV C++,Operating system,Computer

Objective
Program To Find Greater Number
Code

ENGR HASNAIN AHMAD 14


Output

Precautions

ENGR HASNAIN AHMAD 15


LAB #6
Apparatus
Dev C++, Operating System, Computer.

Objective
Program to Use multiple operations to make a Calculator Using Switch
Statements
Code

ENGR HASNAIN AHMAD 16


Output

Precautions

ENGR HASNAIN AHMAD 17


LAB #7

Apparatus
Dev C++, Operating System, Computer.

Objective
Program to Check the Alphabet if “It is Vowel?” by Using Logical
Operators
Code

ENGR HASNAIN AHMAD 18


Output

Precaution

ENGR HASNAIN AHMAD 19


LAB #8

Apparatus
Dev C++, Operating System, Computer.

Objective
Program To find Factorial of Any Number Using Loop Statement
Code

ENGR HASNAIN AHMAD 20


Output

Precaution

ENGR HASNAIN AHMAD 21


LAB #9

Apparatus
Dev C++, Operating System, Computer.

Objective
Program To Sum, Subtract, Multiply and divide numbers using if
statement.

Code

ENGR HASNAIN AHMAD 22


Output

Precaution

ENGR HASNAIN AHMAD 23


LAB #10

Apparatus
Dev C++, Operating System, Computer.

Objective
Program to Add two numbers Using Functions.
Code

ENGR HASNAIN AHMAD 24


Output

Precaution

ENGR HASNAIN AHMAD 25


LAB #11

Apparatus
Dev C++, Operating System, Computer.

Objective
Program to Draw Pascal's triangle

Code

ENGR HASNAIN AHMAD 26


Output

Precaution

ENGR HASNAIN AHMAD 27


LAB #12

Apparatus
Dev C++, Operating System, Computer.

Objective
Program to display Floyd's Triangle.
Code

ENGR HASNAIN AHMAD 28


Output

Precaution

ENGR HASNAIN AHMAD 29


LAB #13

Apparatus
Dev C++, Operating System, Computer.

Objective
Program of Passing by reference using pointers to Swap Numbers.

Code

ENGR HASNAIN AHMAD 30


Output

Precaution

ENGR HASNAIN AHMAD 31

S-ar putea să vă placă și