Sorry my program keeps on giving wrong output someone please if know anything wrong.
Example I put
2
1 3
2 5
The first line is number of inputs
The following line is the cell and maximum units which can be in cell.
The program should find how many total cells remain to reach maximum units.
It output 4195501 instead of 5.
1 2 3 4 5 6 7 8 9 10 11 12 13 14
#include<iostream>
usingnamespace std;
int main(){
int n,cell,max,ans;
cin>>n;
for(int i=0; i<n; i++){
cin>>cell>>max;
ans+=max-cell;
}
cout<<ans;
}