









Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
MCA Docs, MCA Docs, MCA Docs, MCA Docs, MCA Docs, MCA Docs, MCA Docs, MCA Docs, MCA Docs, MCA Docs, MCA Docs, MCA Docs, MCA Docs, MCA Docs, MCA Docs, MCA Docs, MCA Docs, MCA Docs, MCA Docs, MCA Docs, MCA Docs, MCA Docs, MCA Docs, MCA Docs, MCA Docs, MCA Docs, MCA Docs, MCA Docs, MCA Docs, MCA Docs, MCA Docs, MCA Docs, MCA Docs, MCA Docs, MCA Docs, MCA Docs, MCA Docs, MCA Docs, MCA Docs, MCA Docs, MCA Docs, MCA Docs, MCA Docs, MCA Docs, MCA Docs, MCA Docs, MCA Docs, MCA Docs, MCA Docs, MCA Docs,
Typology: Study notes
1 / 15
This page cannot be seen from the preview
Don't miss anything!










Basic syntax and functions from the C++ programming language.
#include
It prints output on the screen cout << "This is C++ Programming";
It takes input from the user cin >> variable_name
The data type is the type of data
Typically a single octet(one byte). It is an integer type char variable_name;
The most natural size of integer for the machine
int variable_name;
A single-precision floating-point value float variable_name;
A double-precision floating-point value double variable_name;
Represents the absence of the type void
bool
It is a sequence of characters starting with a backslash, and it doesn't represent itself when used inside string literal.
It produces a beep sound \a
It adds a backspace
It represents the value of an octal number \nnn
It represents the value of a hexadecimal number \xhh
The null character is usually used to terminate a string \ 0
A comment is a code that is not executed by the compiler, and the programmer uses it to keep track of the code.
// It's a single line comment
/* It's a multi-line comment */
It is a collection of characters surrounded by double quotes
// Include the string library #include
It is used to concatenate two strings string firstName = "Harry "; string lastName = "Bhai"; string fullName = firstName.append(lastName); cout << fullName;
It returns the length of the string string variable1 = "CodeWithHarry"; cout << "The length of the string is: " << variable1.length();
string variable1 = "Hello World"; variable1[ 1 ] = 'i'; cout << variable1;
C++ provides some built-in math functions that help the programmer to perform mathematical operations efficiently.
It returns the larger value among the two
if (condition) { // This block of code will get executed, if the condition is True }
if (condition) { // If condition is True then this block will get executed } else { // If condition is False then this block will get executed }
if (condition) { // Statements; } else if (condition){ // Statements; } else{ // Statements }
It is shorthand of an if-else statement. variable = (condition)? expressionTrue : expressionFalse;
It allows a variable to be tested for equality against a list of values (cases). switch (expression) { case constant-expression: statement1; statement2;
break; case constant-expression: statement; break; ... default: statement; }
Iterative statements facilitate programmers to execute any block of code lines repeatedly and can be controlled as per conditions added by the programmer.
It iterates the block of code as long as a specified condition is True while (/* condition /) { / code block to be executed */ }
It is an exit controlled loop. It is very similar to the while loop with one difference, i.e., the body of the do-while loop is executed at least once even if the condition is False do { /* code / } while (/ condition */);
It is used to iterate the statements or a part of the program several times. It is frequently used to traverse the data structures like the array and linked list. for (int i = 0 ; i < count; i++) { /* code */ }
return_type function_name(data_type parameter...){ //code to be executed }
function_name(arguments);
Recursion is when a function calls a copy of itself to work on a minor problem. And the function that calls itself is known as the Recursive function. void recurse() { ... .. ... recurse(); ... .. ... }
It is a programming approach that primarily focuses on using objects and classes. The objects can be any real-world entities.
class Class_name { public: // Access specifier // fields // functions // blocks };
Class_name ObjectName;
It is a special method that is called automatically as soon as the object is created. class className { // The class public: // Access specifier className() { // Constructor cout << "Code With Harry"; } }; int main() { className obj_name; return 0 ; }
Data encapsulation is a mechanism of bundling the data, and the functions that use them and data abstraction is a mechanism of exposing only the interfaces and hiding the implementation details from the user. #include
It allows us to read the file line by line getline()
It opens a file in the C++ program void open(const char* file_name,ios::openmode mode);
Opens the file to read(default for ifstream) fs.open ("test.txt", std::fstream::in)
Opens the file to write(default for ofstream) fs.open ("test.txt", std::fstream::out)
Opens the file in binary mode fs.open ("test.txt", std::fstream::binary)
Opens the file and appends all the outputs at the end fs.open ("test.txt", std::fstream::app)
Opens the file and moves the control to the end of the file fs.open ("test.txt", std::fstream::ate)
Removes the data in the existing file fs.open ("test.txt", std::fstream::trunc)
Opens the file only if it already exists fs.open ("test.txt", std::fstream::nocreate)
Opens the file only if it does not already exist fs.open ("test.txt", std::fstream::noreplace)
It closes the file myfile.close()
An exception is an unusual condition that results in an interruption in the flow of the program.
A basic try-catch block in python. When the try block throws an error, the control goes to the except block