My issue
My code
// Update the code below to solve this problem
#include <iostream>
#include <string>
using namespace std;
int main()
{
int t;
cin>>t;
while(t--)
{
int P;
cin>>P;
if(P%10==0)
cout<<P/100<<endl;
else if(P>110)
cout<<-1<<endl;
else if(P<100)
cout<<P%100<<endl;
else
cout<<P%100+1<<endl;
}
return 0;
}
Learning course: Solve Programming problems using C++
Problem Link: CodeChef: Practical coding for everyone
include
include
using namespace std;
int main()
{
int t;
cin>>t;
while(t–)
{
int P;
cin>>P;
if(P%100 >10 ){
cout << -1<<endl;
}
else if(P%100 <10 && P>100 && P%100!=0){
int k= (P%100)+1;
cout <<k<<endl;
}
else if(P%100==0 && P>100){
int m= P/100;
cout <<m<<endl;
}
else if(P<=10){
cout <<P<<endl;
}
}
}
i wrote this code and it gives correct output but idk why its showing error
@yashismyname06 According to your code, what will be the output of the input - 1100 ?
can u give the accurate code ?
include
using namespace std;
int main() {
int t;
cin>>t;
while(t–){
int p;
cin>>p;
int i = (p/100)+(p%100);
if(i<=10){
cout<<i<<endl;
}
else{
cout<<-1<<endl;
}
}
return 0;
}
i got this …