0
#include <iostream>
    
int main(){ 
  int maths,science,english;
  char answer; 
    
  std::cout<<"please enter your marks : \n";
    
  std::cin>>maths;  
  std::cin>>science;  
  std::cin>>english;
       
  double percent;
  percent= (maths+science+english)/300;
        
  std::cout<< "your percentage is :"<<percent<<"\n";
}
Nathan Pierson
  • 5,461
  • 1
  • 12
  • 30
  • 2
    When you say the wrong answer, what inputs are you providing, what answer are you getting, and what do you expect the answer to be? My _guess_ is that you're not expecting the correct [behavior from integer division](https://stackoverflow.com/questions/3602827/what-is-the-behavior-of-integer-division). – Nathan Pierson Sep 04 '21 at 17:48
  • Cast any of `math`, `science` or `english` to `double` before dividing, or change the number to `300.0`. – Thomas Matthews Sep 04 '21 at 17:50
  • Change `percent= (maths+science+english)/300;` to `percent= (maths+science+english)/300.0;`. I consider this *the next most vexing parse* (after *the most vexing parse*), because it is silent but deadly. – Eljay Sep 04 '21 at 18:07

0 Answers0