Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- int main()
- {
- int i, num, temp;
- int *result = NULL ;
- printf("Please Enter A Number\n");
- scanf("%d",&num);
- temp = num;
- // Making The Array
- for(i=1;temp!=0;i++)
- {
- result = (int *) realloc(result, i * sizeof(int));
- if( result == NULL)
- {
- printf("Not Enough Memory!!!\n");
- return 0;
- }
- result[i-1] = temp%10;
- temp = temp/10;
- }
- //Printing The Array
- for(i-=2;i>=0;i--)
- {
- printf("%4d",result[i]);
- }
- printf("\n");
- //Free The Array
- free(result);
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement