You are not logged in. Please login at www.codechef.com to post your questions!

×

Find remainder

    #include<iostream>
using namespace std;
int main()
{
    int n,a,b,p;
    cin>>n;
    if(1<=n&&n<=1000)
    {
        for(int i=0;i<=n;i++)
        {
            cin>>a>>b;
            p=a%b;
            cout<<p<<"\n";
        }
    }
    return 0;
}
WHat is wrong in the code

asked 15 Sep '17, 20:16

mahimagoyen's gravatar image

0★mahimagoyen
1
accept rate: 0%

edited 15 Sep '17, 20:19

vijju123's gravatar image

5★vijju123 ♦♦
15.4k12066


for(int i=0;i<=n;i++)

This executes n+1 times, I think you are taking more input than required.

link

answered 15 Sep '17, 20:20

vijju123's gravatar image

5★vijju123 ♦♦
15.4k12066
accept rate: 18%

You are right . May be you have to begin from i=1 .

(15 Sep '17, 21:51) trashmaster2★
toggle preview
Preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported
  • mathemetical formulas in Latex between $ symbol

Question tags:

×155
×70
×2

question asked: 15 Sep '17, 20:16

question was seen: 313 times

last updated: 15 Sep '17, 21:51