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

Computer Theory Question/Answers: Q1. Explain The Structure of C++

Computer Theory
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as ODT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views

Computer Theory Question/Answers: Q1. Explain The Structure of C++

Computer Theory
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as ODT, PDF, TXT or read online on Scribd
You are on page 1/ 2

Computer Theory

Question/Answers
Q1. Explain the structure of C++.
=> C++ is a general-purpose, high-performance programming language
developed by Bjarne Stroustrup in 1983.
Here the structure of C++:

#include<iostream> //Preprocessor Directives

using namespace std; //Allows us to use names like cout, cin without
prefixing with std::

int main (){ //Main function


.
.
// Code inside main function
.
.
return 0; //Used to terminate the program.
}

i) Preprocessor Directives : Preprocessor directives are special instructions in C


and C++ that are processed by the preprocessor before the actual compilation of
the program begins.

ii) Namespaces : Namespaces in C++ are a feature used to organize code into
logical groups and prevent name conflicts.

iii) Main Function : The main() function is the entry point of any C++ program.
Execution starts here.

Q2. What is variable?


=> A variable in C++ (and most programming languages) is a named storage
location in memory used to hold a value.

Types of Variables:
1. Primitive Data Types:
• int: Stores integers (whole numbers) like -5, 0, 10.
• float: Stores floating-point (decimal) numbers like 3.14, -0.001.
• double: Stores double-precision floating-point numbers (more precise than
float).
• char: Stores a single character like 'a', 'B', or '9'.
• bool: Stores a boolean value (true or false).

2. User-defined Data Types:


Variables can also be declared using user-defined types such as:
• struct
• class
• enum

Q3. What is compiler?


=> A compiler is a software program that translates code written in a high-level
programming language into machine code or bytecode that a computer's
processor can understand and execute easily.

Q4. What is IDE?


=> An IDE (Integrated Development Environment) is a software application that
provides a comprehensive environment to developers for writing, testing,
debugging, and managing code.

Q5. What is constant? Explain the types of constant.


=> A constant in programming refers to a value that cannot be changed once it
is defined.
Types of Constants in C++:
1. Literal Constants : Fixed values assigned directly to variables in the code.
These values are used directly in expressions and cannot be changed.
• Integer literals: 10, -5, 0
• Floating-point literals: 3.14, -0.001
• Character literals: 'a', 'B'
• String literals: "Hello World!"

2. Keyword : This defines a variable whose value cannot be changed once


assigned.

• A const variable must be initialized when declared, and its value cannot be altered later in the
program.

You might also like