C : Program for creating structure and accept structure members using structure pointer #2
Oct 28, 2023
Program :
#include<stdio.h>
struct employee
{
int empid;
char name[20];
float salary;
};
int main()
{
struct employee emp;
struct employee *ptr = &emp;
printf("Enter employee id :");
scanf("%d", &ptr->empid);
printf("Enter employee name :");
scanf("%s", &ptr->name);
printf("Enter employee salary :");
scanf("%f", &ptr->salary);
printf("\nEmployee Details :\n");
printf("ID :%d\n", ptr->empid);
printf("Name :%s\n", ptr->name);
printf("Salary :%.2f\n", ptr->salary);
return 0;
}
Output :