Write a Program in C to implement Structure with Functions using 1st Method
#include<stdio.h>#include<conio.h>
struct student
{
int roll;
char name[50];
};
void fun1(struct student s); //Function Prototype
void main()
{
struct student s1,s2;
printf("Enter Roll Number for Student 1\n");
scanf("%d",&s1.roll);
printf("\nEnter Name for Student 1\n");
scanf("%s",&s1.name);
printf("\n\nEnter Roll Number for Student 2\n");
scanf("%d",&s2.roll);
printf("\nEnter Name for Student 2\n");
scanf("%s",&s2.name);
printf("\n\nRoll Number \t Names \n\n");
fun1(s1); //Function call for s1
fun1(s2); //Function call for s2
getch();}
void fun1(struct student s)
{
printf(" %d \t %s \n",s.roll,s.name);
}
No comments:
Post a Comment