Hello there,i am having a bit of trouble here, i am making a program that will average 3 test scores. the scores should be between 0 and 100 and if it does not meet that requirement it will say "invalid score". This is what i got, but i am not sure what is wrong with it. also i have no idea how to get decimal points on the average, need to have 1 number in the decimal area. Thank you.
#include <iostream>
using namespace std;
int main()
{
int score1, score2, score3, sum;
double average;
IT would be better to make a function that prompts for a number inside a loop that checks for out-of-bounds error. if ((score1 > 100) && (score1 < 0))
What number is both greater than 100 and less than 0? average = sum / 3;
Although you've correctly chosen a float instead of an int to store average, sum/3 is computed using integer arithmetic, so it gets truncated. To fix this, change one argument to float or double. The easiest way to do that is just to add a ".0" after 3: average = sum / 3.0;