https://www.bybit.com/register?affiliate_id=38000&group_id=52135&group_type=1
[856x508] Get $90 Rewards

C Programming code for Read & Display of Structures using pointers

Write a Modular C Programming code for Read & Display of Structures using pointers.

Read the number of students, read their information and display the details of the students:

CODE:

#include<stdio.h>
struct student
{
char name[20];
int rno;
float marks;
};
struct student s[50];
struct student *ptr;
void read(struct student s[50], int n);
void display(struct student s[50], int n);
int n, i;

main()
{
    ptr=&s;
printf("\nEnter Details of Student %d",i+1);
read(s,n);
printf("\nThe Details of students %d is: ",i+1);
display(s,n);
}
void read(struct student s[50], int n)
{

printf("\nEnter the Name: ");
scanf("%s",&ptr->name);
printf("Enter the RollNo: ");
scanf("%d",&ptr->rno);
printf("Enter the Marks: ");
scanf("%f",&ptr->marks);
printf("\n+++++++++++++++++++++++++++++++++++++++++++++++++\n");

}
void display(struct student s[50], int n)
{

printf("\nName: %s",ptr->name);
printf("\nRollNo: %d",ptr->rno);
printf("\nMarks: %f",ptr->marks);
printf("\n\n+++++++++++++++++++++++++++++++++++++++++++++++++\n");
}

 

OUTPUT

Enter Details of Student 1
Enter the Name: hudfhfkls
Enter the RollNo: 897
Enter the Marks: 8977

+++++++++++++++++++++++++++++++++++++++++++++++++

The Details of students 1 is:
Name: hudfhfkls
RollNo: 897
Marks: 8977.000000

+++++++++++++++++++++++++++++++++++++++++++++++++

Process returned 0 (0x0)   execution time : 8.024 s
Press any key to continue.

 

Please find some more codes of 1D Arrays, 2D Arrays, Pointers, Data Structures on the below page:

Top 100+ C Programming codes – KLE Technological University

 

Leave a Comment