0% found this document useful (0 votes)
8 views

C++ Internals 1 QB

C++ answers for questions

Uploaded by

1ds22md034
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views

C++ Internals 1 QB

C++ answers for questions

Uploaded by

1ds22md034
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

1.

OOPS and how it is different from procedure oriented

Object-Oriented Programming is a methodology or paradigm to design a program using classes and


objects. It simplifies the software development and maintenance by providing some concept like Class •
Inheritance • Polymorphism • Abstraction • Encapsulation

In procedural programming, the In object-oriented programming,


program is divided into small parts the program is divided into small
called functions. parts called objects.

Procedural programming follows Object-oriented programming


a top-down approach. follows a bottom-up approach.

Object-oriented programming has


There is no access specifier in
access specifiers like private,
procedural programming.
public, protected, etc.

Adding new data and functions is Adding new data and function is
not easy. easy.

Procedural programming does not Object-oriented programming


have any proper way of hiding data provides data hiding so it is more
so it is less secure. secure.

In procedural programming, Overloading is possible in object-


overloading is not possible. oriented programming.

In procedural programming, there is In object-oriented programming,


no concept of data hiding and the concept of data hiding and
inheritance. inheritance is used.

In procedural programming, the In object-oriented programming,


function is more important than the data is more important than
data. function.

2.ADVANTAGES OF OOPS PROGRAMMING:

i. OOPs makes development and maintenance easier where as in Procedure-oriented programming


language it is not easy to manage if code grows as project size grows.
ii. OOPs provide data hiding whereas in Procedure-oriented programming language a global data can be
accessed from anywhere.

iii. OOPs provide ability to simulate real-world event much more effectively. We can provide the solution
of real word problem if we are using the Object-Oriented Programming language.

3. OPERATORS IN C++

(in book)

4. BASIC STRUCTURE OF C++


#include<IOSTREAM> : includes the standard input output library functions. It provides cin and cout
methods for reading from input and writing to output respectively.

#include<CONIO.H>: includes the console input output library functions. The getch() function is defined
in conio.h file.

int main() : The main() function is the entry point of every program in C++ language. The void keyword
specifies that it returns no value.

Cout << "Welcome to C++ Programming." is used to print the data "Welcome to C++ Programming."

5. IDENTIFIER VS KEYWORDS

A keyword is a predefined and reserved word that carries special meaning. You cannot use it as a
variable name, constant name etc.

No symbols can be used.

Ex: int, float, switch, else

Identifer are unique names given to variables, classes , functions or etc by the programmer. They are
usually variables.

Can have symbols.

Ex: int sum; here sum is the identifier

Float salary; salary is the identifier

6. TOKEN, CONSTANT, EXAMPLES

A C++ program is composed of tokens which are the smallest individual


unit. Tokens can be one of several things, including keywords, identifiers, constants,
operators, or punctuation marks.
Ex: keywords, identifiers

a constant is a value that cannot be changed during the execution of the program.
Constants often represent fixed values used frequently in the code, such as the
value of pi or the maximum size of an array.

Ex: #include <iostream>


using namespace std;
int main()
{
// Define a constant named "PI" of type double and initialize it to 3.14159
const double PI = 3.14159;
cout << "The area of the circle is " << area << "." << endl;
return 0;
}

7. INSERTION AND EXTRACTION OPERATOR

INSERTION

The cout is used in conjunction with stream insertion operator (<<)

The insertion operator ( << ) points to the ostream object wherein the information is inserted.

cout << is used for displaying the message or a result of an expression.

EXTRACTION

The cin is used in conjunction with stream extraction operator (>>) to read the input from a console.

cin is an istream object from which information can be extracted. used to EXTRACT the information or
the value of a variable

Cin>> is used for taking values from user

8. USE OF CLASS AND OBJECTS IN C++ PROGRAM


9. DIFFERENCE IN MAIN() IN C AND C++

 In C++ we cannot call a main() function from any other point. The
main() function is the single execution point.

 However, in C language, we can have a main() function called by


the other functions in the code.

 In C, the main() function has a fixed signature


 In C++, the main() function can have two alternative signatures: int
main() or int main(int argc, char* argv[])

 C does not support function overloading, which means you cannot have
multiple functions with the same name but different parameter lists.

 C++, you can overload the main() function, providing different versions
with varying parameters.
 In C, if the main() function does not explicitly return a value,

 In C++, if the main() function does not contain a return statement, the
compiler implicitly adds a return 0; at the end of the function.

 C does not have namespaces


 In C++, the main() function can be placed inside a namespace,

10. APPLICATION OF OOPS


GAMES: as it is closer to hardware;;; can manipulate resources and override the
complexities of 3d games
GUI BASED APPLICATIONS: most apps from Adobe, like photoshop
WEB BROWSER: Mozilla, Chrome and google file sharing
EMBEDDED SYSTEMS: Smart watches, medical equipment
BANKING APPLICATION: as these need concurrency, multi threading and high
performance. Infosys Finacle
DATABASE MANAGEMENT SYSTEMS: mySQL is written in c++

13. RULES FOR NA MING VARIABLES IN C++, HOW THEY DIFFER FROM ANSI C

You might also like