0

I made a program to convert decimal to octal but it's printing the output in reverse order. Is there maybe a way to store the data that the program is printing so that i can reverse it?

#include <stdio.h>

int main(){
    int n;
    printf("Enter the interger");
    scanf("%d",&n);
    int q=n;
    if (n<8)
        printf("%d",n);
    else{
        while(q>=8){
            int r=q%8;
            q=q/8;
            printf("%d",r);

        }
    printf("%d",q);
    }
    return 0;
}
Eyy boss
  • 105
  • 3

0 Answers0