21st Oct 2019, 6:28 PM
Mahmoud Qasrawi
Mahmoud Qasrawi - avatar
6 Answers
+ 1
// Created by Mahmoud Qasrawi #include <iostream> using namespace std; int main() { char c; float x, y, z, av, sum; cout<< "if you want to calculate the avareg of three numbers enter A please and if you want to calculate the summation of tow numbers enter S please "<<endl; cin>>c; if ((c=='a')||(c=='A')) { cin>>x; cin>>y; cin>>z; av=(z+y+x)/3.0; cout<<"the average is"<<av; } else if ((c=='s')||(c=='S')) {sum=x+y; cout<<"the summation is"<<sum; } else cout<<"invaild input!!!!"; return 0; }
21st Oct 2019, 7:34 PM
Abdulmalek Mohammed Jayash
Abdulmalek Mohammed Jayash - avatar
+ 1
Give input as ::: a 1 2 3 then submit. It will print 2
22nd Oct 2019, 5:51 AM
NAVNEET BISHT
NAVNEET BISHT - avatar
0
Change:- #include <iostream> int main(); char c; To:- #include <iostream> using namespace std; int main() { char c;
21st Oct 2019, 7:03 PM
rodwynnejones
rodwynnejones - avatar
0
The wrong you don't give the variables x , y , z value So the program cant calculate the average Solution: Give the variables initial values or let the user input them there values . Ex: x =7; y=56; z=13 ; Then run the code
21st Oct 2019, 7:16 PM
Abdulmalek Mohammed Jayash
Abdulmalek Mohammed Jayash - avatar
0
I want the user to put the values
21st Oct 2019, 7:17 PM
Mahmoud Qasrawi
Mahmoud Qasrawi - avatar
0
You have to delete this character ( } ) from line 9 Then after if ((c == 'a' )|| (c=='A')){ // Wright this code cin>>x ; cin>>y; cin>>z; //Then write your code as it in the document av = ...........
21st Oct 2019, 7:27 PM
Abdulmalek Mohammed Jayash
Abdulmalek Mohammed Jayash - avatar