Open In App

C++ File Format | .cpp Extension

C++ is a general-purpose programming language that extends C with features such as classes and objects, allowing for object-oriented programming. A C++ programming language file has a .cpp file extension. It allows developers to write clean and efficient code for large applications and software development, game development, and operating system programming.

History of C++

C++ was developed by Danish computer scientist Bjarne Stroustrup in the early 1980s. Stroustrup began working on what would become C++ in 1979 at Bell Labs. Stroustrup’s work resulted in the creation of a new language called “C with Classes” in 1983. C++ was further defined with the release of C++03, C++11, C++14, C++17, and C++20. Each new version added new features, improvements, and enhancements to the language, addressing issues and adapting to shifting programming paradigms. C++ became popular because of its flexibility, efficiency, and broad applicability. It has been widely used in systems programming, game development, embedded systems, high-performance computing, and more.

Features of C++

It is an imperative and compiled language. C++ has several features, including:



Syntax of C++




#include <iostream>
using namespace std;
 
int main() {
 
    cout << "GFG!";
    return 0;
}

Code Explanation:

Advantages of C++

Disadvantages of C++

Example Code: Simple program to add two number




#include <iostream>
 
int main() {
    // Declare variables to store user input
    double num1, num2;
 
    // Prompt the user to enter the first number
    std::cout << "Enter the first number: ";
    std::cin >> num1;
 
    // Prompt the user to enter the second number
    std::cout << "Enter the second number: ";
    std::cin >> num2;
 
    // Calculate the sum of the two numbers
    double sum = num1 + num2;
 
    // Display the result
    std::cout << "The sum of " << num1 << " and " << num2 << " is: " << sum << std::endl;
 
    // Return 0 to indicate successful program execution
    return 0;
}

Output:

Enter the first number: 10

Enter the second number: 20

The sum of 10 and 20 is: 30

Conclusion

At last, C++ is one of the favorite languages used by developers when it is time to work in the field of game applications, operating system development, and many more things. C++ GUI support gives leverage to the developer to build complex applications. The .cpp file extension can be only used for C++ program files.


Article Tags :