NO

Author Topic: Help  (Read 3239 times)

Danca

  • Guest
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: 536
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.

Danca

  • Guest
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)

Danca

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

Offline jj2007

  • Member
  • *
  • Posts: 536
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);
   }

Danca

  • Guest
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 »

Danca

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