Twitter Feed Facebook Google Plus Youtube

Adsense responsive

Recent Post below header

Friday, 12 April 2013

C PROGRAM: TO PASS STRUCTURE TO A FUNCTION AS ARGUMENT USING POINTER

CODING:
#include<conio.h>
#include<stdio.h>
struct stud_record
{
 char name[25];
 char cls[5];
 int roll_no;
};
struct stud_record fun(struct stud_record *p);
void main()
{
 struct stud_record student,*s;
 clrscr();
 s=&student;
 fun(s);
 printf("RECORD ENTERED\nName: %s\n",s->name);
 printf("Class: %s",s->cls);
 printf("\nRoll no. %d",s->roll_no);
 getch();
}
struct stud_record fun(struct stud_record *p)
{
 printf("Enter name: ");
 scanf("%s",p->name);
 printf("Enter class: ");
 scanf("%s",p->cls);
 printf("Enter roll no.: ");
 scanf("%d",&p->roll_no);
 printf("\n\n");
}


CODING
OUTPUT


For any query or suggestion please comment below...

No comments:

Post a comment