Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

function using structure

0 votes
asked Feb 28, 2019 by divyabharathi (120 points)

1 Answer

0 votes
answered Mar 1, 2019 by root
#include <stdio.h>
struct student
{
    char name[50];
    int age;
};

// function prototype
void display(struct student s);

int main()
{
    struct student s1;

    printf("Enter name:");
    scanf ("%[^\n]%*c", s1.name);

    printf("Enter age:");
    scanf("%d", &s1.age);
    
    display(s1);   // passing structure as an argument
    
    return 0;
}
void display(struct student s) 
{
  printf("\nDisplaying information\n");
  printf("Name: %s", s.name);
  printf("\nRoll: %d", s.age);
}
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...