C++ PROJECT
C++ PROJECT
C++ PROJECT
ON
C++ PROGRAMMING
BACHELOR OF TECHNOLOGY
IN
COMPUTER SCIENCE OF ENGINEERING
SUBMITTED TO SUBMITTED BY
What is C++?
C++ is a cross-platform language that can be used to create high-performance
applications.
C++ gives programmers a high level of control over system resources and memory.
The language was updated 4 major times in 2011, 2014, 2017, and 2020 to C++11,
C++14, C++17, C++20.
C++ can be found in today's operating systems, Graphical User Interfaces, and
embedded systems.
C++ is portable and can be used to develop applications that can be adapted to
multiple platforms.
Popular IDE's include Code::Blocks, Eclipse, and Visual Studio. These are all free, and
they can be used to both edit and debug C++ code.
C++ Quickstart
Let's create our first C++ file.
Write the following C++ code and save the file as myfirstprogram.cpp (File > Save File
as):
myfirstprogram.cpp
#include <iostream>
using namespace std;
int main() {
cout << "Hello World!";
return 0;
}
C++ Syntax
Let's break up the following code to understand it better:
Example
#include <iostream>
using namespace std;
int main() {
cout << "Hello World!";
return 0;
}
Example
#include <iostream>
using namespace std;
int main() {
cout << "Hello World!";
return 0;
}
2.TECHNOLOGY USED :
C++:
C++ gives programmers a high level of control over system resources and memory.
The language was updated 4 major times in 2011, 2014, 2017, and 2020 to C++11,
C++14, C++17, C++20.
\
3.OBJECTIVES OF PROJECT:
Prerequisites:
Experience with a high level language (C, Java, MATLAB) is a prerequisite.
Learning Objectives:
1. Object-Oriented
2. Speed
When speed is a critical metric, C++ is the most preferred choice. The compilation and
execution time of a C++ program is much faster than most general-purpose programming
languages.
3. Compiled
Unlike other programming languages where no compilation is required, every C++ code has to
be first compiled to a low-level language and then executed.
The C++ Standard Template Library (STL) has many functions available to help write code
quickly. For example, there are STLs for various containers like hash tables, maps, sets, etc.
5. Pointer Support
C++ also supports pointers which are often not available in other programming languages.
6. Closer to Hardware
C++ is closer to hardware than most general-purpose programming languages. This makes it
very useful in those areas where hardware and software are closely coupled together, and low-
level support is needed at the software level.
5. DISADVANTAGES OF C++ PROGRAMMING:
1. The main disadvantage of C++ is that it is a very complex programming language to learn. If you
are new to learning to code and are not familiar with any other object-orientated programming
languages then it can take a very long time to understand, which limits what you can do with it to
begin with.
2. Many people also see this difficulty as a disadvantage as C++ is pretty inaccessible unless you’re
an accomplished programmer, meaning that it gets ignored in favour of other, simpler languages.
3. One of the key features that make C++ a distinctive programming language is the use of pointers.
Whilst these are very useful, they can take up a lot of system memory which is not ideal when
you’re working on large projects. Pointers can also be tricky to get your head around, and using
them incorrectly can cause your whole system to crash or behave strangely, which is a major
drawback.
4. Using an object-oriented programming language like C++ comes with several security issues
because of features like pointers, friend functions and global variables.
5. Although having control of managing memory is seen as an advantage by many people, having to
manually allocate memory using pointers can be very time consuming and easy to forget when
you are in the middle of coding. If you’re not used to doing this then this manual memory
management is a big disadvantage of C++, as there is no garbage collector feature to automatically
filter out unnecessary data.
6. Finally, when you’re coding in C++ the language is unable to support built-in code threads. This is
a key drawback as the majority of other languages have this function, and it can make your
process a lot slower and more complicated.
(II) PROJECT DESIGN PHASE
(III) IMPLEMENTATION PHASE
C++ CODE:
#include<iostream>
#include<conio.h>
int main(){
string questions[10] = {
"Which of the following is Tricontinental Country?",
"Famous fast food restaurant company Burger King belongs to which Country?",
"Office of strategic service (OSS) was old name of which Intelligence agency?",
"The first person to draw the map of earth?",
"Who laid first step on the Moon?",
"What is the name of Chinese parliament?",
"Ogaden desert is present in__________?",
"Capital of America is___________?",
"Wadi Rum which resemblance to the surface of Mars is located in__________?",
"Borneo Island is in which Ocean?"
};
string options[10][4] = {
{"chad","Chile","Mali","Swaziland"},
{"America","England","Turkey","None of these"},
{"MI6","CIA","ISI","N.O.T"},
{"Heraclitus","phythagoras","Anaximander","Thales"},
{"LMP Edgar","CMP Stuart","Neil Armstrong","None of them"},
{"National Assembly","National people’s Congress","Fedral parliament","None"},
{"Europe","Asia","Africa","America"},
{"Washington Dc","Alaska","Hawaii","California"},
{"Argentina","Israel","Jordan","Egypt"},
{"Indian Ocean","Pacific Ocean","Arctic Ocean","Atlantic"},
};
string correctOptions[10] = {
"Chile","America","CIA","Anaximander",
"Neil Armstrong","National people’s Congress","Africa",
"Washington DC","Jordan","Pacific Ocean"
};
int userOptions[10] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
int totalQs = 10;
int op;
int correct = 0;
int incorrect = 0;
int skipped = 0;
for( int i=0; i<totalQs; i++ ){
if( userOptions[i] != 0 ){
if( correctOptions[i] == options[i][userOptions[i]-1] ){
correct++;
}else{
incorrect++;
}
}else{
skipped++;
}
}
cout<< "Total Questions : "<< totalQs <<endl;
cout<< "Correct : "<< correct <<endl;
cout<< "In-Correct : "<< incorrect <<endl;
cout<< "Skipped : "<< skipped <<endl;
getch();
return 0;
}
Screenshots of the project are as follows:
OUTPUT:
Screen 1
Screen 2
Screen 3
(IV) CONCLUSION
1. The state pattern is very powerful indeed. It facilitates breaking your program code into
discrete states. This approach has been used successfully in the telecom industry for
decades to produce what is arguably the most solid software in the world. As you can
see, it’s pretty easy to implement state management in C++. With it, you have the ability
to add code in a very structured fashion—just create a new State subclass interface and
implementation file pair. Then just add this code wherever you need it in the program, as
in Listing 8.
2. The state pattern can be used effectively with a small investment in coding. The source
code for this article consists of five C++ header files and five accompanying C++
implementation files. To build this code and try it for yourself, just create a Visual C++
console project, drop the files in, switch off precompiled headers, and away you go!
(V) REFERENCES
1. www.youtube.com
2. www.geeksforgeeks.com
3. www.w3school.com