Array to store integers and string
I want to store 7 integers and 7 string in array
Here is program to store 7 integers
Code:
#include <stdio.h>
int main()
{
int i;
int date[8]= {1,2,3,4,5,6,7};
for ( i = 0; i < 7; i++)
printf ("Date %d\n", date[i]);
return 0;
}
Here is program to store 7 strings
Code:
#include <stdio.h>
int main()
{
int i;
char days[8][9] = {"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"};
for ( i = 0; i < 7; i++)
printf ("Day %s \n", days[i]);
return 0;
}
I have few doubts
What is meaning of this line
Code:
int date[8]= {1,2,3,4,5,6,7};
I have declared and initialize array
Does it line mention that 7 integers has been stored ?
Code:
char days[8][9] = {"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"};
Does it line mention that 7 string has been stored ?
If we want to store multiple variables then we use array. I think both lines are storing integers and strings