C programming #include<stdio.h> #include <stdlib.h> void read(struct Employee *e
ID: 3859130 • Letter: C
Question
C programming
#include<stdio.h>
#include <stdlib.h>
void read(struct Employee *e);
struct Employee
{
int id;
int age;
};
int main(){
struct Employee e;
read(&e);
}
void read(struct Employee *e){
int a,b;
printf("Enter the id employee ");
scanf("%d",&a);
printf("Enter the age employee ");
scanf("%d",&b);
e->id=a;
e->age=b;
}
Question: Declare a pointer variable of type Employee and place the address of the variable created in the above problem in that pointer variable.
Explanation / Answer
Answer:
The declaration of a pointer variable of type Employee and place the address of the variable created in the above problem in that pointer variable is as written as struct Employee *e; and the modified program is written as below :
#include<stdio.h>
#include <stdlib.h>
void read(struct Employee *e);
struct Employee
{
int id;
int age;
};
int main(){
struct Employee *e;
read(&e);
}
void read(struct Employee *e){
int a,b;
printf("Enter the id employee ");
scanf("%d",&a);
printf("Enter the age employee ");
scanf("%d",&b);
e->id=a;
e->age=b;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.