News:

Download Pelles C here: http://www.smorgasbordet.com/pellesc/

Main Menu

Help

Started by Danca, February 06, 2017, 06:40:59 PM

Previous topic - Next topic

Danca

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

jj2007

Post what you have coded so far (complete code please), and indicate what exactly doesn't work as expected.

Danca

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

Alrady did, thanks anyway

jj2007

Glad you found it :)
   for(i=vf;i>=vi;i--){
   printf("%i ", i);
   }

Danca

Yeah was that, thanks a lot :)

Grincheux

#6
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.

Danca

Well, i think that could work too.