Problem
Write a C++ Program to Find Sum and Average of three numbers.
Solution
Here’s a sample code snippet demonstrating how you can find the sum and average of 3 numbers in C++.
#include<iostream> using namespace std; int main() { float a,b,c,sum,avg; a=10; b=11; c=12; sum=a+b+c; avg=sum/3; cout<<"\nThe SUM of 3 Numbers ="<<sum<<"\n"; cout<<"The AVERAGE of 3 Numbers = "<<avg<<"\n"; return 0; }
Leave a Reply