Wont't ask for userinput

Also I think certain variables aren't being initialized as well mainly 'b'.

#include "stdafx.h"
#include <iostream>
#include <cmath>
#include<iomanip>

using namespace std; 


int _tmain(int argc, _TCHAR* argv[])
{
	float a,b,c,avg,pro;
	char choice;

	
	
	cout<<"Enter three three-digit numbers, seperated by spaces: ";
		cin >> a,b,c;
	
	cout<<"Enter 'a' to average the number or 'p' to caculate the product: ";
		cin >> choice;
		
         
		if(choice == 'a')
		{
			avg=((a*b*c)/3);
			cout<<"The average of "<<a<<", "<<b<<" and "<<c<<" is "<<setiosflags(ios::fixed)<<setprecision(2) <<avg;
		}
		if(choice == 'p')
		{
			pro=(a*b*c);
			cout<<"The product of "<<a<<", "<<b<<" and "<<c<<" is "<<setiosflags(ios::fixed)<<setprecision(2) <<pro;
		}
		


	return 0;
}


It just says hit any key to continue failing to let user enter a or p to provide either average or product.
Last edited on
replace
cin >> a,b,c;
with
cin >> a >> b >> c;

also, if you truly mean "average", replace (a*b*c)/3 with (a+b+c)/3
lol thanks so much. Yeah I meant that don't know why I multiplied them.

So that's why a b and c never got initialized. I wasn't calling them correctly for cin.

For some reason I thought separating them with commas would work. Thanks for your hep!
Topic archived. No new replies allowed.