Hey guys, just wanted to first off say thanks for all the help in the past.
I was wondering how to go about finding the first digit from a number inputted into an array.
Thank you for any help.
ex.
enter the numbers to use:
9
45
682
120
output:
the numbers are 9 4 6 and 1
Here is what I have, the array goes to a max of 15 for the moment, but I allow the user to input as large an array as they want up to that number. Then the user is to input it's numbers.
Code:
#include <stdio.h>
#define MAX 15
int main()
{
int array[MAX]; /*Array to place numbers in*/
int num; /*Amount of number to use in game*/
int num1; /*Number to be inputted for game*/
int i, j, k;
printf("How many numbers would you like to have?\n");
scanf("%d", &num);
for(i = 0; i < num ; i++){ /*Starts loop to input numbers into array*/
scanf("%d", &num1);
array[i] = num1;
}
printf("\n");
for(k = 0; k < num; k++){ /*Loop prints the array*/
printf("%d ", array[k]);
}
return 0;
}