About C++

Data Structures

Print a String

Odd Number Programme

Odd or Even Number Programme

Factorial Programme

C++

C++ is a powerful programming language that’s ideal for creating big applications like video games and operating systems. It boasts features like virtual functions, templates, and exception handling, making it a popular choice for programmers worldwide. C++ has a wealth of libraries and frameworks developed by the community to enhance its functionality. Overall, C++ is a great tool in a programmer’s arsenal for creating excellent software.

STRUCTURES IN  C++

C++ is an ideal option for efficient data storage and handling, as it provides a wide range of data structures that cater to varying data management needs. The main advantage of using C++ is its flexibility in organizing data using different structures such as arrays, pointers, structures, classes, and unions. To conclude, C++ offers an extensive range of data structures that provide maximum efficiency in managing big and complex data sets.

ARRAYS AND POINTERS

Using arrays can simplify data management by keeping data values in contiguous memory locations, while pointers are perfect for accessing data from specific memory locations. This grants users the ability to create dynamic data structures like linked lists and trees. Structures in C++ are useful in grouping data variables under a single entity and provide an easy way to access related data within the same group.

CLASSESS AND UNIONS

Classes provide encapsulation and abstraction and are critical in object-oriented programming, while unions enable accessing the same memory location as multiple data types for optimized programming processes. 

PRINT PROGRAMME  C++

#include <iostream>

int main() {

    // Declare a string variable to hold user input

    std::string userInput;

    // Prompt the user to enter a string

    std::cout << “Enter a string: “;

  // Read user input from the console   

 std::getline(std::cin, userInput);

  // Print the user input on the console

    std::cout << “You entered: ” << userInput << std::endl;

    return 0;

}

 

ODD NUMBER PROGRAMME IN C++

#include <iostream>

using namespace std;

 

int main() {

    int limit;

    cout << “Enter the limit: “;

    cin >> limit; //Input limit from user

 

    for(int i=1; i<=limit; i+=2) {

        cout << i << ” “; //Print odd numbers

    }

   return 0;

}

ODD OR EVEN NUMBER PROGRAMME IN C++

#include <iostream>

using namespace std;

 

int main() {

   int num;

   cout << “Enter a number: “;

   cin >> num;

   if (num % 2 == 0) {

       cout << “The number entered is even.” << endl;

   } else {

       cout << “The number entered is odd.” << endl;

   }

   return 0;

}

FACTORIAL PROGRAMME IN C++

#include <iostream>

using namespace std;

int factorial(int n)

{

    if (n == 0) return 1;

    return n * factorial(n-1);

}

int main()

{

    int n;

    cout << “Enter a number: “;

    cin >> n;

    cout << n << “! = ” << factorial(n) << endl;

    return 0;

 

}

Scroll to Top