C++

C++ Program to Find Average of Marks2 min read

Formula: Average=Obtain Marks * 100 / Total Marks will be used in this program to find Average of marks in C++

This code calculates the average of a student’s marks based on their obtained marks and the total marks of the exam.




Here’s a brief breakdown of what the code does:

The #include<iostream> line includes the input/output stream library in the program, which allows us to use input/output functions such as cin and cout.

The using namespace std; line allows us to use the standard C++ library without having to specify the std:: prefix for every function.

The int main() function is the entry point of the program. This is where the program begins executing.

The float variables total, obt, and avg are declared to store the total marks, obtained marks, and average, respectively.

The program prompts the user to enter their obtained marks by printing the message “Enter Your Obtained Marks : ” on the screen, and then reads the value entered by the user and stores it in the obt variable using the cin function.

The program then prompts the user to enter their total marks and reads the value entered by the user, storing it in the total variable.

The average is calculated by dividing the obtained marks by the total marks and storing the result in the avg variable.

The average is then printed on the screen using the cout function.

The return 0; statement at the end of the main() function indicates that the program has completed successfully.

Output:

C++ Program to Find Average of Marks Code
C++ Program to Find Average of Marks Code
C++ Program to Find Average of Marks
C++ Program to Find Average of Marks

2 Comments

    • Here is a simple C++ program that adds two numbers and prints the result:

      #include
      using namespace std;

      int main()
      {
      int a, b, sum;

      cout << "Enter two integers: "; cin >> a >> b;

      sum = a + b;
      cout << "Sum = " << sum; return 0; } This program prompts the user to enter two integers, reads the values entered by the user, and stores them in the variables a and b. The sum of a and b is then calculated and stored in the sum variable. Finally, the sum is printed on the screen using the cout function. I hope this helps! Let me know if you have any questions.

Leave a Comment