C++ Exercises: Compute the specified expressions and print the output
C++ Basic: Exercise-35 with Solution
Write a program in C++ to compute the specified expressions and print the output.
Sample Solution:
C++ Code:
#include <iostream> // Including the input-output stream header file
using namespace std; // Using the standard namespace
int main() // Start of the main function
{
cout << "\n\n Compute the specified expressions and print the output:\n"; // Outputting a message indicating the purpose of the program
cout << "------------------------------------------------------------\n"; // Outputting a separator line
// Calculating and outputting the result of the given expression
cout << " Result of the expression "
<< "(25.5 * 3.5 - 3.5 * 3.5) / (40.5 - 4.5) is : " // Outputting the expression
<< (25.5 * 3.5 - 3.5 * 3.5) / (40.5 - 4.5) << "\n"; // Calculating and outputting the result of the expression
return 0; // Returning 0 to indicate successful program execution
}
Sample Output:
Compute the specified expressions and print the output: ------------------------------------------------------------ Result of the expression (25.5 * 3.5 - 3.5 * 3.5) / (40.5 - 4.5) is : 2.13889
Flowchart:
C++ Code Editor:
Previous: Write a C++ program to display the current date and time.
Next: Write a program in C++ to test the Type Casting.
What is the difficulty level of this exercise?
It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.
https://w3resource.com/cpp-exercises/basic/cpp-basic-exercise-35.php
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics