I need help with this problem that I was given at my school. The problem is writen in Serbian, I'll try my best to translate it.
Write a program that enters n elements of a one-dimensional array and then displays their ordinal number, index and value (see test example)
The test example is in Serbian as well, but I think you can guess what do you need to do. Here is what I tried to do:
#include <stdio.h>
#include <stdlib.h>
int main()
{
int n,i,clan,broj=0,b,a;
a=1;
printf("Unesi broj elementa niza:\n");
scanf("%d", &n);
for (i=1;i<=n;i++)
{
printf("Unesi %d clan niza:\n", i);
printf("a[%d]=", broj);
broj++;
scanf("%d", &clan);
}
for (b=1;b<=n;b++)
{
printf("%d. clan niza je a[%d]=%d\n", a, b, clan);
a++;
}
return 0;
}
Everything works fine except that "clan" will only show as the latest entered number.