Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

C++ PROJECT

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 17

PROJECT REPORT

ON

C++ PROGRAMMING

BACHELOR OF TECHNOLOGY
IN
COMPUTER SCIENCE OF ENGINEERING

OF IKG PUNJAB TECHNICAL UNIVERSITY, JALANDHAR

SUBMITTED TO SUBMITTED BY

MRS. AMANDEEP BENIPAL Gaurav singh rawat


2002429

DEPARTMENT OF CSE, DEPARTMENT OF CSE,


CEC LANDRAN CEC LANDRAN
(I) INTRODUCTION

1.INTRODUCTION OF THE PROJECT:

What is C++?
C++ is a cross-platform language that can be used to create high-performance
applications.

C++ was developed by Bjarne Stroustrup, as an extension to the C language.

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.

Why Use C++


C++ is one of the world's most popular programming languages.

C++ can be found in today's operating systems, Graphical User Interfaces, and
embedded systems.

C++ is an object-oriented programming language which gives a clear structure to


programs and allows code to be reused, lowering development costs.

C++ is portable and can be used to develop applications that can be adapted to
multiple platforms.

C++ is fun and easy to learn!

As C++ is close to C, C# and Java, it makes it easy for programmers to switch to C++


or vice versa.
C++ Install IDE
An IDE (Integrated Development Environment) is used to edit AND compile the code.

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.

Note: Web-based IDE's can work as well, but functionality is limited.

We will use Code::Blocks in our tutorial, which we believe is a good place to start.

You can find the latest version of Codeblocks at http://www.codeblocks.org/. Download


the mingw-setup.exe file, which will install the text editor with a compiler.

C++ Quickstart
Let's create our first C++ file.

Open Codeblocks and go to File > New > Empty 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;
}

C++ Output (Print Text)


The cout object, together with the << operator, is used to output values/print text:

Example
#include <iostream>
using namespace std;

int main() {
  cout << "Hello World!";
  return 0;
}
2.TECHNOLOGY USED :

C++:

C++ is a cross-platform language that can be used to create high-performance


applications.

C++ was developed by Bjarne Stroustrup, as an extension to the C language.

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:

C++ Programming is intended for software engineers, systems analysts, program


managers and user support personnel who wish to learn the C++ programming language.

Prerequisites:
Experience with a high level language (C, Java, MATLAB) is a prerequisite.

Learning Objectives:

 The learning objectives of this course are:


 To understand how C++ improves C with object-oriented features.
 To learn how to write inline functions for efficiency and performance.
 To learn the syntax and semantics of the C++ programming language.
 To learn how to design C++ classes for code reuse.
 To learn how to implement copy constructors and class member functions.
 To understand the concept of data abstraction and encapsulation.
 To learn how to overload functions and operators in C++.
 To learn how containment and inheritance promote code reuse in C++.
 To learn how inheritance and virtual functions implement dynamic binding with polymorphism.
 To learn how to design and implement generic classes with C++ templates.
 To learn how to use exception handling in C++ programs.
Advantages of C++

1. Object-Oriented

C++ is an object-oriented programming language which means that the main focus is on


objects and manipulations around these objects. This makes it much easier to manipulate code,
unlike procedural or structured programming which requires a series of computational steps to
be carried out.

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.

4. Rich Library Support

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:

The disadvantages of C++ programming are mentioned below:

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

Code of the project is as follows:\

C++ CODE:
#include<iostream>
#include<conio.h>

using namespace std;

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;

    //----- Conducting Quiz -----


    for( int i=0; i<totalQs; i++ ){
        cout<<"Question # "<<(i+1)<<endl;
        cout<< questions[i]<<endl;
        cout<< "1."<<options[i][0]<<endl;
        cout<< "2."<<options[i][1]<<endl;
        cout<< "3."<<options[i][2]<<endl;
        cout<< "4."<<options[i][3]<<endl<<endl;
    
        cout<<"Select Option (1-4) or 0 to skip and press enter: ";
        cin >> userOptions[i];
        cout<<endl<<"-----------------------------"<<endl<<endl;
  }
  
    //----- Printing Correct Options -----
    cout<<"======= ======= ======= ======= "<<endl;
    cout<<"======= Correct Options ======= "<<endl;
    cout<<"======= ======= ======= ======= "<<endl;

    for( int i=0; i<totalQs; i++ ){


        cout<<"Question # "<<(i+1)<<endl;
        cout<< questions[i]<<endl;
        cout<< "1."<<options[i][0]<<endl;
        cout<< "2."<<options[i][1]<<endl;
        cout<< "3."<<options[i][2]<<endl;
        cout<< "4."<<options[i][3]<<endl;
    
        if( userOptions[i] == 0 ){
            cout<< "You Skipped this Question."<<endl;      
        }else{
            cout<< "You Selected : "<<options[i][userOptions[i]-1]<<endl;      
    }
        cout<< "Correct Option : "<<correctOptions[i]<<endl<<endl;

        cout<<"Press any key to continue..."<<endl;


        getch();
        cout<<endl<<"------------------"<<endl;
  }
  
    //----- Printing Result -----
    cout<<endl<<endl;
    cout<<"======= ======= ======= ======= "<<endl;
    cout<<"=======      Result     ======= "<<endl;
    cout<<"======= ======= ======= ======= "<<endl;

    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

You might also like