Saturday, August 18, 2018

SIMPLE STRUCTURE


  • Problem Description

    Write a C program to Store Information and Display it Using Structure
  • CODING ARENA
  • #include <stdio.h>
    int main()
    {
      struct student
      {
        char name[80];
        int roll_no;
        float marks;
      };
      struct student stud1;
      scanf("%s",stud1.name);
      scanf("%d",&stud1.roll_no);
      scanf("%f",&stud1.marks);
      printf("Name=%s\n",stud1.name);
      printf("Roll number=%d\n",stud1.roll_no);
      printf("Marks=%.1f\n",stud1.marks);
        

    return 0;
    }
  • Test Case 1

    Input (stdin)
    Abi
    
    1001
    
    99.5
    
    
    Expected Output
    Name=Abi
    
    Roll number=1001
    
    Marks=99.5
  • Test Case 2

    Input (stdin)
    Akash
    
    1002
    
    90.3
    
    
    Expected Output
    Name=Akash
    
    Roll number=1002
    
    Marks=90.3

No comments:

Post a Comment