(i) Given an integer number, write a program that displays the number as follows :
First Line : all digits
Second Line : all excepts first digits
Third Line : all excepts first two digits
………..
Last Line : the last digit.
For example, the number 5678 will be displayed as :
5 6 7 8
6 7 8
7 8
8
Solution:
#include<stdio.h>
int main(){
int x,arr[16],i=0,j;
printf("Enter the integer value: ");
scanf("%d",&x);
while(x > 0){
arr[i]= x % 10;
x = x / 10;
i++;
}
for(j=i-1; j >= 0; j--){
for(i=j; i>=0;i--){
printf("%d ",arr[i]);
}
printf("\n");
}
return 0;
}