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

Ai Chat Bot

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

PROJECT REPORT

ON

C++ PROGRAMMING

BACHELOR OF TECHNOLOGY
IN
COMPUTER SCIENCE OF ENGINEERING

OF IKG PUNJAB TECHNICAL UNIVERSITY, JALANDHAR

SUBMITTED TO SUBMITTED BY

MRS.KAMALJEET KAUR 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 <windows.h>
#include <stdio.h>
#include <string.h>
#include <ctime> // must include this header file to use time function

using namespace std;

// function to wish user according to time


void wishme(){
// current date and time based on your system timezone
time_t now = time(0);
tm *time = localtime(&now);

if (time-> tm_hour < 12){


cout<< "Good Morning Sir"<<endl;
string phrase = "Good Morning Sir";
string command = "espeak \"" + phrase + "\"";
const char *charCommand = command.c_str();
system(charCommand);
}

else if (time-> tm_hour >= 12 && time->tm_hour <= 16){


cout<< "Good Afternoon sir"<<endl;
string phrase = "Good Afternoon sir";
string command = "espeak \""+ phrase + "\"";
const char *charCommand = command.c_str();
system(charCommand);
}

else if (time-> tm_hour > 16 && time->tm_hour < 24){


cout<< "Good Evening sir"<<endl;
string phrase = "Good Evening sir";
string command = "espeak \"" + phrase + "\"";
const char *charCommand = command.c_str();
system(charCommand);
}
}

void datetime(){
time_t now = time(0);
char *dt = ctime(&now);
cout<<"The date and time is "<<endl
<< dt <<endl;
}

int main()
{
system("cls");

cout<<"\t\t\t<============================================= W E L C O M E
==========================================>"<<endl;
cout<<"\t\t\t<============================================= I'M A VIRTUAL
ASSISTANT ==========================================>"<<endl;
cout<<"\t\t\t<============================================= MY NAME IS
GAURAV ==========================================>"<<endl;
cout<<"\t\t\t<============================================= I'M HERE TO HELP
YOU ==========================================>"<<endl<<endl;

char password[20]; //to take password


char ch[100]; // to take command from the user

do
{
cout<<"======================="<<endl;
cout<<"| ENTER YOUR PASSWORD |"<<endl;
cout<<"======================="<<endl<<endl;
string phrase = "enter your password";
string command = "espeak \"" + phrase + "\"";
const char *charCommand = command.c_str();
system(charCommand);

gets(password);

STARTUPINFO startInfo = {0};


PROCESS_INFORMATION processInfo = {0};

if(strcmp(password, "chintu")==0){
cout<<"\
n<========================================================================
==========================>\n\n";
wishme();
do{
cout<<"\
n<========================================================================
==========================>\n\n";
cout<<endl<<"How can i help you sir...."<<endl<<endl;

string phrase = "How can i help you sir";


string command = "espeak \"" + phrase + "\"";
const char *charCommand = command.c_str();
system(charCommand);

cout<<"Your query ===> ";


gets(ch);
cout<<endl;
cout<<"Here is the result for your query ===> ";

if(strcmp(ch, "hi") == 0 || strcmp(ch, "hey") == 0 || strcmp(ch, "hello") == 0 ){


cout<<"Hello sir....."<<endl;
string phrase = "Hello sir";
string command = "espeak \"" + phrase + "\"";
const char *charCommand = command.c_str();
system(charCommand);
}

else if(strcmp(ch, "bye") == 0 || strcmp(ch, "stop") == 0 || strcmp(ch, "exit") == 0 ){


cout<<"Good Bye sir, have a nice day!!!!"<<endl;
string phrase = "Good Bye sir, have a nice day";
string command = "espeak \"" + phrase + "\"";
const char *charCommand = command.c_str();
system(charCommand);
exit(0);
}

else if(strcmp(ch, "who are you") == 0 || strcmp(ch, "tell me about yourself") == 0 ||


strcmp(ch, "about") == 0 ){
cout<<"I'm a virtual assistant created by Aditi !!!"<<endl;
string phrase = "I am a virtual assistant created by Aditi";
string command = "espeak \"" + phrase + "\"";
const char *charCommand = command.c_str();
system(charCommand);
}

else if(strcmp(ch, "how are you") == 0 || strcmp(ch, "whatsup") == 0 || strcmp(ch, "how is


your day") == 0 ){
cout<<"I'm good sir, tell me how can i help you.."<<endl;
string phrase = "I'm good sir, tell me how can i help you";
string command = "espeak \"" + phrase + "\"";
const char *charCommand = command.c_str();
system(charCommand);
}

else if(strcmp(ch, "time") == 0 || strcmp(ch, "date") == 0){


// make function to show date and time
datetime();
}
else if(strcmp(ch, "open notepad") == 0){
cout<<"openining notepad....."<<endl;
string phrase = "opening notepad";
string command = "espeak \"" + phrase + "\"";
const char *charCommand = command.c_str();
system(charCommand);
CreateProcess(TEXT("C:\\Windows\\notepad.exe"), NULL, NULL, NULL, FALSE,
NULL, NULL, NULL, &startInfo, &processInfo);
}
else if(strcmp(ch, "open google") == 0){
cout<<"opening google....."<<endl;
string phrase = "opening google";
string command = "espeak \"" + phrase + "\"";
const char *charCommand = command.c_str();
system(charCommand);
system("start https://www.google.com");
}

else if(strcmp(ch, "open youtube") == 0){


cout<<"opeining YouTube....."<<endl;
string phrase = "opening youtube";
string command = "espeak \"" + phrase + "\"";
const char *charCommand = command.c_str();
system(charCommand);
system("start https://www.youtube.com");
}

else if(strcmp(ch, "open instagram") == 0){


cout<<"openining instagram....."<<endl;
string phrase = "opening instagram";
string command = "espeak \"" + phrase + "\"";
const char *charCommand = command.c_str();
system(charCommand);
system("start https://www.instagram.com");
}
else{
cout<<"Sorry could not understand your query please ty again !!!"<<endl;
string phrase = "Sorry could not understand your query please ty again";
string command = "espeak \"" + phrase + "\"";
const char *charCommand = command.c_str();
system(charCommand);
}
}while(1);
}
else
{
system("cls");

cout << "\t\t\t<============================= W E L C O M


E=============================>" << endl;
cout << "\t\t\t<============================= I'M VIRTUAL ASSISTANT
=============================>" << endl;
cout << "\t\t\t<============================= MY NAME IS Gaurav
=============================>" << endl;
cout << "\t\t\t<============================= I'M HERE TO HELP YOU AND
MAKE YOUR LIFE EASY =============================>" << endl
<< endl;

cout << "======================" << endl;


cout << "X Incorrect Password X" << endl;
cout << "======================" << endl
<< endl;
string phrase = "Incorrect Password, Please enter correct password";
string command = "espeak \"" + phrase + "\"";
const char *charCommand = command.c_str();
system(charCommand);
}
} while (1);

return 0;
}
Screenshots of the project are as follows:
OUTPUT:
Screen 1 

Screen 2
(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