Store and Retrieve Data Using an Array of Structures in Interactive Mode - C Structure

C examples for Structure:Structure Value

Description

Store and Retrieve Data Using an Array of Structures in Interactive Mode

Demo Code

#include <stdio.h>
#include <string.h>
  struct biodata {
    char name[15];
    int rollno;//from www.  j  a v  a  2s  .com
    int age;
    float weight;
  } ;

int linkfloat()
{
      float number = 10, *pointer;
      pointer = &number;
      number = *pointer;
      return(0);
}
int main(){
     int i;
    
     struct biodata agents[5];
    
     for(i = 0; i < 5; i++) {
           printf("# %d: \n", i+1);
           printf("Name: ");
           scanf("%s", &agents[i].name);
           printf("Roll Number: ");
           scanf("%d", &agents[i].rollno);
           printf("Age: ");
           scanf("%d", &agents[i].age);
           printf("Weight: ");
           scanf("%f", &agents[i].weight);
     }
    
     for(i = 0; i < 5; i++) {
           printf("Biodata of Secret Agent # %d: \n", i+1);
           printf("\tName: %s\n", agents[i].name);
           printf("\tRoll Number: %d\n", agents[i].rollno);
           printf("\tAge: %d years \n", agents[i].age);
           printf("\tWeight: %.1f kg\n\n", agents[i].weight);
     }
    
     return (0);
}

Result


Related Tutorials