Canna

Saturday, 15 June 2019

Structure 42

  • Problem Description

    Write a program , using a pointer to a structure to initialize the members of the structure to display the students course registration details where details of first student initialized in the program and details of second student get from the user , then display the details of both student 1 and student 2

    Input and Output Format:

    Refer sample input and output for formatting specification.

    All float values are displayed correct to 2 decimal places.

    All text in bold corresponds to input and the rest corresponds to output.

    Note:

    Use structure and union concepts
  • Test Case 1

    Input (stdin)
    12
    
    ram
    
    it
    
    2333
    
    
    Expected Output
    Roll no:12
    
    Name:ram
    
    Course:it
    
    Fees:2333
  • Test Case 2

    Input (stdin)
    15
    
    john
    
    cse
    
    15000
    
    
    Expected Output
    Roll no:15
    
    Name:john
    
    Course:cse
    
    Fees:15000
  • Program
  • #include <stdio.h>
      struct data
    {
      char name[50]; 
        char course[50];
      int roll; 
         int fees;
    };
    int main()
    {
        char name[50];
      char course[50];
      int roll;
      int fees;
         scanf("%d",&roll );
      
          scanf("%s",name);
      
         scanf("%s",course);
      
          scanf("%d",&fees); 
      
        printf("Roll no:%d\n",roll );
        printf("Name:%s\n",name);
        printf("Course:%s\n",course);
        printf("Fees:%d\n",fees);
        
      
      
     return 0;
    }

No comments:

Post a Comment

Note: only a member of this blog may post a comment.