Program to store and display the name, rollno and fees of a student using structure. Pass the member of structure variable to a function called display() to display the contents.

C File =>


/* Write a C program to store and display the name, rollno and fees of a student using structure. Pass the member of structure variable to a function called display() to display the contents.*/

#include<stdio.h>
#include<stdlib.h>
typedef struct Student
{
int rno;
char name[30];
float fees;
};

//global declaration of structure member
struct Student s;


int main() {
      printf("\n Enter Roll number : ");
      scanf("%d",&s.rno);
      printf("\n Enter name : ");
      scanf("%s",s.name);
      printf("\n Enter fees : ");
      scanf("%f",&s.fees);
     void display(struct Student s)
    {
       printf("\n\n Roll number : %d",s.rno);
       printf("\n Name : %s",s.name);
       printf("\n Fees : %f",s.fees);
    }
    display(s);
    return 0;
 }

Comments

Popular posts from this blog

Write a program to allocate memory dynamically for n integers. Accept the elements and calculate their sum and average

C program to accept names of n cities and search for city named “Pune”.