I'm Jitesh a programmer trying to involve in C programming. I'm having a problem in initializing arrays in C.
#include <conio.h>
void disp( char ch)
{
printf("%c", ch);
}
int main(){
char arr[10];
int count = 0, iterator = 0;
for(int iterator=0; iterator<10; iterator++){
printf("\nAlphabet %d:", count + 1);
scanf("%c", &arr[iterator]);
}
for (int x=0; x<10; x++)
{
/* Iām passing each element one by one using subscript*/
disp (arr[x]);
}
return 0;
}
I'm trying to input the variable in the array and print out the array. The output should look like this.
Alphabet 1: A //A is inputted variable
Alphabet 2: B
Alphabet 3: C
Alphabet 4: A
Alphabet 5: C
Alphabet 6: A
Alphabet 7: B
Alphabet 8: C
Alphabet 9: A
Alphabet 10: C
A B C A C A B C A C
Do help me out by providing the full solution