A PHP Error was encountered

Severity: 8192

Message: str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated

Filename: libraries/Filtered_db.php

Line Number: 23

C program to read and print student details using structure pointer, demonstrate example of structure with pointer.
Q:

C program to read and print student details using structure pointer, demonstrate example of structure with pointer.

0

C program to read and print student details using structure pointer, demonstrate example of structure with pointer.

In this C program, we are going to learn how to read and print a student’s details? Here, we are using structure pointer to implement this program. This is an example of structure with pointer.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Program

/*C program to read and print student details using structure pointer, 
demonstrate example of structure with pointer.*/

#include <stdio.h>
 
struct student{
    char    name[30];
    int     roll;
    float   perc;
};

int main()
{
    struct student  std;        //structure variable
    struct student  *ptr;       //pointer to student structure
     
    ptr= &std;                  //assigning value of structure variable
     
    printf("Enter details of student: ");
    printf("\nName ?:");        gets(ptr->name);
    printf("Roll No ?:");       scanf("%d",&ptr->roll);
    printf("Percentage ?:");    scanf("%f",&ptr->perc);
     
    printf("\nEntered details: ");
    printf("\nName:%s \nRollNo: %d \nPercentage: %.02f\n",ptr->name,ptr->roll,ptr->perc);

    return 0;
}

Output

    Enter details of student: 
    Name ?:Mike
    Roll No ?:101
    Percentage ?:89.7

    Entered details: 
    Name:Mike 
    RollNo: 101 
    Percentage: 89.70

 

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now