Program that accepts temperature of 7 days from user and print their average using array

7 days temperature from user and print their average using array

Write a program that accepts temperature of 7 days from user and print their average using array

Object: Write a program that accepts temperature of 7 days from user and print their average using array. C++ projects for beginners with source code

Code:

#include<iostream>
#include<conio.h>
using namespace std;
void main()
{
float temp[7],sum=0,avg;
int i;
cout<<“Enter 7 days Tempreature:\n”;
for(i=0;i<7;i++)
{
cin>>temp[i];
sum+=temp[i];
}
avg=sum/7;
cout<<“Average of 7 days Temperature is:”<<avg;
getch();
}

#include<iostream>
#include<conio.h>
using namespace std;
void main()
{
	float temp[7],sum=0,avg;
	int i;
	cout<<"Enter 7 days Tempreature:\n";
	for(i=0;i<7;i++)
	{
		cin>>temp[i];
		sum+=temp[i];
	}
	avg=sum/7;
	cout<<"Average of 7 days Temperature is:"<<avg;
	getch();
}

Output:

Program that accepts temperature of 7 days from user and print their average using array

1 thought on “Program that accepts temperature of 7 days from user and print their average using array”

Leave a Comment

Your email address will not be published. Required fields are marked *