This repository has been archived on 2023-10-26. You can view files and clone it, but cannot push or open issues or pull requests.
VSMechatronics/Lectures/LC19/Structure2/Structure_2.c

39 lines
702 B
C
Raw Normal View History

2022-04-07 15:58:01 +00:00
#include <stdio.h>
#include <stdlib.h>
struct DataSet /* Define a struture called DataSet */
{
int x; /* The X data */
int y; /* The Y data */
};
int main(void)
{
struct DataSet MyPoints[5]; /* Define array of structure, */
/* type DataSet */
/* Elements : 5 */
2022-04-07 15:58:01 +00:00
int i; /* Define an integer */
for ( i = 0 ; i < 5 ; i++ ) /* Populate structure */
{
MyPoints[i].x = i;
MyPoints[i].y = i*i;
2022-04-07 15:58:01 +00:00
}
printf("\nThe dataset values are "); /* Display message & Values */
for ( i = 0 ; i < 5 ; i++ )
{
printf("\n\t Set %d : ",i);
printf("\t X = %d ",MyPoints[i].x);
printf("\t Y = %d ",MyPoints[i].y);
2022-04-07 15:58:01 +00:00
}
return 0;
}