I am using for-loops to read and print the values. As you can see it stores only the last input. Any suggestions?
#include <stdio.h>
int main()
{
int i;
for(int a = 0; a < 5; a ++)
{
printf("Enter your age: ");
scanf("%d", &i);
}
for(int b = 0; b < 5; b ++)
{
printf("Hi I'm %d years old\n", i);
}
return 0;
}
And here's the output . .
Enter your age: 11
Enter your age: 22
Enter your age: 33
Enter your age: 44
Enter your age: 55
Hi I'm 55 years old
Hi I'm 55 years old
Hi I'm 55 years old
Hi I'm 55 years old
Hi I'm 55 years old