NO

Author Topic: Help  (Read 446 times)

Offline Danca

  • Member
  • *
  • Posts: 5
Help
« on: February 06, 2017, 06:40:59 PM »
Program that can read  two  number int between [100;999]
And write the sequencial number between final number and inical number
Exemp. inicial number? 255
Final number? 263 Output: 263, 262, 261, 260, 259, 258, 257, 256, 255

Offline jj2007

  • Member
  • *
  • Posts: 454
Re: Help
« Reply #1 on: February 07, 2017, 02:18:16 AM »
Post what you have coded so far (complete code please), and indicate what exactly doesn't work as expected.

Offline Danca

  • Member
  • *
  • Posts: 5
Re: Help
« Reply #2 on: February 07, 2017, 05:12:19 PM »
int main(int argc, char *argv[])
{
   int vi;
   int vf;
   int i;
   

   printf("Digite o seu numero inicial");
   scanf("%d",&vi);

   printf("Digite o seu numero final ");
   scanf("%d",&vf);

   for(i=0;i<vf;i--){
   }
   

(Inside printf  is portuguese)

Offline Danca

  • Member
  • *
  • Posts: 5
Re: Help
« Reply #3 on: February 07, 2017, 05:50:14 PM »
Alrady did, thanks anyway

Offline jj2007

  • Member
  • *
  • Posts: 454
Re: Help
« Reply #4 on: February 07, 2017, 07:35:09 PM »
Glad you found it :)
Code: [Select]
   for(i=vf;i>=vi;i--){
   printf("%i ", i);
   }

Offline Danca

  • Member
  • *
  • Posts: 5
Re: Help
« Reply #5 on: February 08, 2017, 04:39:11 PM »
Yeah was that, thanks a lot :)

Grincheux

  • Guest
Re: Help
« Reply #6 on: February 13, 2017, 06:05:06 PM »
What about vi < vf or vi = vf :o

vi = min(vi,vf) ;
vf = max(vi,vf) ;

if(vi != vf)
{
   while(++vi < vf)
   {
        printf("%i\n",vi) ;
   }
}

Use unsigned int rather than int.
« Last Edit: February 13, 2017, 06:13:16 PM by Grincheux »

Offline Danca

  • Member
  • *
  • Posts: 5
Re: Help
« Reply #7 on: February 18, 2017, 09:07:03 PM »
Well, i think that could work too.