- #1
leroyjenkens
- 616
- 49
Hello, here is my program. It let's a user put in numbers and then gives them back to the user reversed. Can someone help me separate this program into functions, with the part that reverses the numbers being in its own function?
I'm still struggling figuring out how to separate programs I make into functions.
Code:
#include <stdio.h>
#include <stdlib.h>
int main()
{
int readNum;
int numbers[50];
printf("How many numbers would you like to enter? ");
scanf("%d", &readNum);
printf("\nEnter your numbers: ");
for (int i = 0; i < readNum; i++)
scanf("%d", &numbers[i]);
printf("\nYour numbers reversed are: ");
for (int i = readNum - 1, numPrinted = 0; i >= 0; i--)
{
printf("%d", numbers[i]);
if (numPrinted < 9)
numPrinted++;
else{printf("\n");
numPrinted = 0;}
}
return 0;
}
I'm still struggling figuring out how to separate programs I make into functions.