बिजनेस मार्केटिंग का लो कॉस्ट फंडा , अपने मोबाइल से ऑटो sms भेजकर मार्केटिंग करे विजिट करे http://autotextsms.com/ बिजनेस मार्केटिंग का लो कॉस्ट फंडा http://autotextsms.com/

Search This Blog

Translate

c structure program example accept structure element and print using function

c program structure using function

write a simple c program which accept structure element and print it  using function. (use call by value )

 how to write a simple c program which accept structure element and print it  using function use call by value and call by reference example with source code , structure using function and pointer program example with source code.


#include<stdio.h>

#include<conio.h>
struct stud{ int rno;char nm[20];};
void pr(struct stud s);
void main()
{
 struct stud s1;
  clrscr();
  printf("enter structure element : \n ");
  scanf("%d",&amp;s1.rno);
  fflush(stdin);
  gets(s1.nm);
  pr(s1);
  getch();

}
void pr(struct stud s)
{ printf("\n_____________________\n");
 printf("id=%d  Name=%s",s.rno,s.nm);
}


output:

c program structure using function and Pointer

write a simple c program which accept structure element and print it  using function (use call by reference )

#include<stdio.h>

#include<conio.h>
struct stud{ int rno;char nm[20];};
void pr(struct stud *s);
void main()
{
  struct stud s1;
  clrscr();
  printf("enter structure element : \n ");
  scanf("%d",&amp;s1.rno);
  fflush(stdin);
  gets(s1.nm);
  pr(&amp;s1);
  getch();

}
void pr(struct stud *s)
{
 printf("\n_____________________\n");
 printf("id=%d  Name=%s",s-&gt;rno,s-&gt;nm);

}

C Program example List