In: Computer Science
Define parallel arrays, tell how the data in each array is accessed and give an example of parallel arrays.
Define parallel arrays, tell how the data in each array is accessed and give an example of parallel arrays.
Answer:
Parallel arrays:
two or more arrays of the same size are called parallel arrays
the arrays are the same data types or different data types
how the data in each array is accessed:
the data accessed from arrays by using the index value
using index value only data accessed from parallel arrays
example of parallel arrays.
CODE:
#include <stdio.h>
int main()
{
int i;
//parallel arrays
int Id[3]= {101,102,103};
char names[3][10]={"Ramesh","Saisri","Suresh"};
float Salary[3]={20000.00,25000.00,22000.00};
//print parallel arrays by using index value.
printf("ID NAMES SALARY\n");
for(i=0;i<3;i++)
{
printf("%d %s %.2f\n",Id[i],names[i],Salary[i]);
}
return 0;
}
OUTPUT:
SCREENSHOT OF THE CODE: