Code:
#include <stdio.h>
#include <conio.h>
struct emp
{
char name[25];
int age;
int salary;
};
void fn1(char*,int,int);
void main()
{
struct emp emp_1[3];
int i;
for(i=0;i<3;i++)
{
printf("Enter name age and salary of number %d\n",i);
scanf("%s%d%d",&emp_1[i].name,&emp_1[i].age,&emp_1[i].salary);
}
for(i=0;i<3;i++)
{
fn1(emp_1[i].name,emp_1[i].age,emp_1[i].salary);
}
getch();
}
void fn1(char *ch,int a,int b)
{
printf("\n\nName is %s\nAge is %d\nSalary is %d\n",ch,a,b);
}
That above is my answer to the qtn.
WAP to accept values in structure array and pass it to a function to print the values
Is there any way that I can pass the whole structure to fn1 without putting it in a for loop?
Code:
for(i=0;i<3;i++)
{
fn1(emp_1[i].name,emp_1[i].age,emp_1[i].salary);
}
just straightaway like
Code:
void fn1(struct emp empl_1)
or something like that?
Thanks in advance