0% found this document useful (0 votes)
96 views

C Program

This C code defines a student structure with name and age fields, declares a display function to print student details, defines a main function to get student input, call display function to print the student's name and age, and defines the display function to print the passed student's name and age.

Uploaded by

Praveena Gopi
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
96 views

C Program

This C code defines a student structure with name and age fields, declares a display function to print student details, defines a main function to get student input, call display function to print the student's name and age, and defines the display function to print the passed student's name and age.

Uploaded by

Praveena Gopi
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 2

Compute the age of a person using structure and functions

#include <stdio.h>

struct student {
char name[50];
int age;
};
void display(struct student s); // function prototype
int main() {
struct student s1;
printf("Enter name: ");
// read string input from the user until \n is entered
// \n is discarded
scanf("%[\n]%*c", s1.name);
printf("Enter age: ");
scanf("%d", &s1.age);
display(s1); // passing struct as an argument
return 0;
}
void display(struct student s) {
printf("\nDisplaying information\n");
printf("Name: %s", s.name);
printf("\nAge: %d", s.age);}
Compute the number of days an employee came late to the office by
considering his arrival time for 30 days (Use array of structures and
functions)

include <stdio.h>

/*structure declaration*/
struct employee{
char name[30];
};

You might also like