//ok i need to write a programme that asks the user to input student numbers as an array and check the initial number and allocate them into different classrooms.. my code looks lik ths:
#include <stdio.h>
int number;
int i;
int student_number[10];
int total;
int first[0];
int main (void)
{
printf("Enter the total number of students ");
scanf("%d", &total);
for (i=1; i<=total; i++)
{
printf("Enter the student number\n: ");
scanf("%d", &student_number);
printf("first digit is %d\n", student_number[0]);
if (student_number[0] < 5)
{
printf(" Classroom A\n");
}
else if (student_number[0] >5)
{
printf(" Classroom B\n");
}
}
system ("pause");
return 0;
}
the code only works if there is a space between the digits, ie. if input is 23 3, i get the first digit as 23. what should i do so that it extracts the first digit from the number with no spaces in between?