Help me in solving BMMC19 problem

My issue

My code

// Update the code below to solve the problem

#include <iostream>
#include <string>
using namespace std;

int main() 
{
 int t;
 cin>>t;
for(int i=0;i<=t;i++)
 { 
   int X,P,Q;
   cin>>P>>Q>>X;
   cout<<X*(P-Q)<<endl;
   
  }
  
 return 0;
}

Learning course: Solve Programming problems using C++
Problem Link: CodeChef: Practical coding for everyone

Problems in your code:

  1. If you are initializing the for loop from 0 then you have to carried it till (i<t).
  2. You have to correct the sequence of your literals while using “cin”.

here’s the corrected code for your problem:

#include
#include
using namespace std;

int main()
{
int t;
cin>>t;
for(int i=0;i<t;i++)
{
int X,P,Q;
cin>>X>>P>>Q;
<<X*(P-Q)<<endl;

}

return 0;

}

1 Like