0% found this document useful (0 votes)
7 views2 pages

Average and Basic Math Operations Code

Uploaded by

ffire55969
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views2 pages

Average and Basic Math Operations Code

Uploaded by

ffire55969
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Find the average of 3 numbers.

#include

using namespace std;

int main() {

float num1, num2, num3, average;

cout << "Enter three numbers: ";

cin >> num1 >> num2 >> num3;

average = (num1 + num2 + num3) / 3;

cout << "Average = " << average << endl;

return 0;

Check whether the number is positive, negetive or zero

#include

Using namespace std;

Int main() {

Int num;

Cout << "Enter a number: ";

Cin >> num;

If (num > 0)

Cout << "The number is positive." << endl;

Else if (num < 0)

Cout << "The number is negative." << endl;

Else
Cout << "The number is zero." << endl;

Return 0;

Sample calv2 numbers

#include

Using namespace std;

Int main() {

Float a, b;

Cout << "Enter two numbers: ";

Cin >> a >> b;

Cout << "Sum = " << a + b << endl;

Cout << "Difference = " << a – b << endl;

Cout << "Product = " << a * b << endl;

If (b != 0)

Cout << "Quotient = " << a / b << endl;

Else

Cout << "Division by zero is not allowed." << endl;

Return 0;

You might also like