jeudi 21 janvier 2021

need help understanding C++? [closed]

Question is The user enters three negative integers A, B and C. Display in reverse order all
numbers from the interval from A to B that are less than C (A <B, positive order - increasing, reverse order - decreasing).

int reversDigits(int num) 

{

int rev_num = 0; 

while (num > 0) 

{ 

    rev_num = rev_num*10 + num%10; 

    num = num/10; 

} 

return rev_num; 

}

/* Driver program to test reversDigits */

int main()

{

int num = 5896; 

printf("Reverse of no. is %d", reversDigits(num)); 

return 0; 

}

Aucun commentaire:

Enregistrer un commentaire