Given the value of num, this functionshould display num with spaces in between.
ID: 3614567 • Letter: G
Question
Given the value of num, this functionshould display num with spaces in between. This functionshould not return any result to the main program.
Given the value of num, this functionshould display the reversed form of num. This function shouldnot return any result to the main program.
Given the value of num, this functionshould return the reversed form of num to the main program. The reversed form must be displayed in the main program.
Example:
Enter num: 671235
Display with spaces: 6 7 1 2 3 5
Reversed num: 532176
Reversed num: 532176
Explanation / Answer
please rate - thanks #include #include void displayWithSpaces(int); void reverseNum(int); int reverseNum2(int); int main() {int a; printf("Enter a number: "); scanf("%d",&a); displayWithSpaces(a); reverseNum(a); printf("Reversed: %d ",reverseNum2(a)); getch(); return 0; } void displayWithSpaces(int a) {int b; printf("With spaces: "); b=reverseNum2(a); while(b>0) {printf("%d ",b%10); b/=10; } printf(" "); } void reverseNum(int a) {printf("Reversed: "); while(a>0) {printf("%d",a%10); a/=10; } printf(" "); } int reverseNum2(int a) {int b=0; while(a>0) {b=b*10+a%10; a/=10; } return b; }Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.