Skip to main content

Posts

Showing posts from May, 2025

C++ Day 39

  C++ Day 39 STL Containers (Deep Understanding & Real Usage) Till now, you already know arrays, vectors, loops, and STL algorithms. Today, we go one step deeper and understand STL containers , which are the backbone of modern C++ programming. In real projects and competitive coding, choice of container matters a lot. 1. What are STL Containers? STL containers are data structures provided by C++ to store data efficiently. They handle: memory management resizing element access performance optimization You focus on logic , not memory handling. 2. Categories of STL Containers STL containers are mainly divided into: Sequence Containers Associative Containers Unordered Containers Container Adapters 3. Sequence Containers These store data in sequence . 3.1 Vector Most used container in C++. vector< int > v; Key Features: Dynamic size Contiguous memory Fast random access Slower insertion in middle Example: v. push_...

C++ Day 8

  Great! On ** day 8 ** of a specific C ++ course, you will usually go into one of these main subjects: , ## ✅ ** string in C ++ ** Strings are sequence of characters. C ++ provides two main methods of working with them: 1. ** C-style strings ** (character arrays) 2. ** c ++ 'string' class ** (from standard library) We will focus on both. , ### 🔹 1. ** C-style strings (character arrays) ** `` `CPP #INCLUDE <iostream> #INCLUDE <CSTRING> using namespace std; int main() { Four names [20]; Cout << "Enter your name:"; Cin >> Name; Cout << "Hello," << Name << "!" << Endl; Return 0; , , #### Useful C-Style String Functions' <cstring> `: * `Strlen () - String length * `Strcpy ()` - Copy Strings * 'Strcat () ` - Constenate * 'Strcmp () ` - Compare `` `CPP Char Str1 [] = "Hello"; char str2 [] = "world"; Cout << Strcat (Str1, Str2); // Hello Worl...

C++ Day 7

  very nice! You are moving well. ** Day 7 ** On a specific ** c ++ course **, you will usually cover: , ## ✅ ** Multi -time arrays (2D arrays) ** ### 🔹 1. ** Introduction to 2D arrays ** A 2D array is like a table - ** with rows and columns **. `` `CPP #INCLUDE <iostream> using namespace std; int main() { Int matrix [2] [3] = { {1, 2, 3}, {4, 5, 4} , // Row 1, access element on column 2 cout << Matrix [1] [2]; // Output: 6 Return 0; , , , ### 🔹 2. ** Input and output in a 2D array ** `` `CPP int main() { Int Arr [2] [3]; // input For (int i = 0; i <2; i ++) { For (int j = 0; j <3; j ++) { Cout << "Enter the element [" << I << "] [" << j << "]:"; CIN >> arrest [i] [j]; , , // Output cout << "\ Nmatrix: \ n"; For (int i = 0; i <2; i ++) { For (int j = 0; j <3; j ++) { ...

C++ Day 6

  Fabulous Often 6 days of C ++ course are addressed: Angians are fine in C ++. Arrays save several values ​​of the same type under a variable. , 1. What is an array? A collection of array elements, stored in embodied memory sites. , #INCLUDE <iostream> using namespace std; int main() INT Number [5] = {10, 20, 30, 40, 50}; // Elements access cout << "first element:" << number [0] << Endl; Return zero; , , , ## 2. Using input and output arrays `` `CPP int main() Int Marx [5]; // input For (int i = 0; i <5) cout << i+1 << ":"; Enter the mark; Cin marks [i]; , // Output cout << recorded marks: For (int i = 0; i <5; i ++) { Cout << "Mark" << i+1 << ":" << Marks [i] << Endl; , Return 0; , , , 3. Array , Int Arr1 [4] = {1, 2, 3, 4}; // All the members initialized Int Arr2 [5] = {1, 2}; , , 4. Find maximum elements in an array `` `CPP int main() Int Nums [] = {12, 45, 23, 67,...

C++ Day 5

  Remarkable! Typically found on day five of a C++ course are loops, arrays, or functions depending on the course. Typically, Day 5 of an introductory C++ course comprises as follows: - Subjects for Day 5: C++ Function 1. Start of Function Functions help you to organize consistent blocks of your code. ``` #include iostream Employ the std namespaces. null greeting() Cout < "Hello from a function! & endl } int Main Greetings; // Phone by method reconciliation zero; 2. operational parameters ``` cpp void welcomeUser (String name) cout << << "Hello, " << << name << << "! " endl; { int main() Greetings Alice. Hello users Bob. Going back to zero; } - Usability for value returning c ++ int add ( a, int b) return a + b; }} int main result = add(5, 3); cin & lt; Sum: & lt; end Back 0: } ``` --- Additional causes: overburthen of labor For several actions with the same name, different attributes could be defined. ``` int...

C++ Day 4

 Great progress! Let’s jump into Day 4 of C++ learning. Today, you'll explore arrays , strings , and basic loops with data structures . C++ Day 4: Arrays and Strings 🔹 1. Arrays An array is a collection of elements of the same data type , stored in contiguous memory locations. ✅ Declaration: int numbers[5]; // uninitialized int scores[5] = {10, 20, 30, 40, 50}; // initialized ✅ Accessing Elements: std::cout << scores[2]; // Output: 30 ✅ Looping Through an Array: for (int i = 0; i < 5; i++) { std::cout << scores[i] << " "; } 🔹 2. Multidimensional Arrays ✅ Example: 2D Array (Matrix) int matrix[2][3] = { {1, 2, 3}, {4, 5, 6} }; ✅ Accessing: std::cout << matrix[1][2]; // Output: 6 🔹 3. Strings in C++ C++ offers two ways to handle strings: ✅ C-style strings (char arrays) char name[] = "Alice"; std::cout << name; ✅ C++ string class (recommended) #include <string> std::string nam...

C++ Day 3

Great!   Welcome to Day 3 of learning C++.   Today, we will explore fundamental parameter passing, scope, and functions.   Writing modular, reusable, clean code depends on these fundamental ideas. C++ Day 3: Scope and Functions 1.   What is a Function? A task done by a block of code known as a function is Functions help to divide a big program into more manageable parts. 2.   Function Syntax return_type function_name(parameter1, parameter2, .   .   .   ) { // Code to run value return; // if return_type is not void { ✅ Example: int add(int a, int b) return a + b; } int main std::cout << add(5, 3); // Output: 8 return 0. }} Three kinds of functions: Void functions lack return value. Return-type functions: Give back a value. Parameterless functions: No input Parameterized functions: Accept input four.   Definition versus Declarations of Function Prototype declaration: Tells the compiler a function exist: int multiple(int, int); Definition:...

C++ Day 2

Great! Focus on control structures—the basic ingredients for creating choices and loops in your code—let's go on to C++ instruction Day 2. C++ Day 2: Control Systems 1. Declarations Made Conditional These are supporting choices taken in your code. Should Statements: int age = 18; if (age >= 18) { std::cout << "You are an adult. "; } Statements of if-else int age = 16; if (age >= 18) { std::cout << "You are an adult. "; Else, std::cout << You are a minor. } Else-if stairway Marks are 85. marks are 90 or more std::cout << "Grade A"; else marks are 75 or more: std::cout << "Grade B"; Otherwise : std::cout << "Grade C"; } 2. Change Statements Useful for comparing a variable to several constant values. int choice = 2; case choice: case 1 Std::cout << "Option 1"; rest Case 2: std::cout << "Option 2"; pause; default: std::cout << "Invalid choice"; }...

C++ Day1

Theoretically part will begin day one of our C++ course.   The fundamental concepts are: Day 1: Basics of C++: What is C++? A broad, compiled, high-performance programming language is C++.   Essentially C with object-oriented features, it is a superset. It was designed by Bjarne Stroustrup early in the 1980s. It assists procedural, object-oriented, and generic programming. Embedded firmware, driver creation, game development, system/software development, client-server applications, and embedded firmware are among C++'s most important uses. Basics C++ Program Structure: # include int main() { // Starting point of the main function std::cout < ; Return 0; }} Explanations: Add &lt;iostream; this covers the library for input and output. int main() { .   .   .   }; the primary function—every execution begins here. std::cout displays output. Return 0: The software ran without mistake. Concerning the Basics: Variable and Data Type Variables house values. Usual k...