My Profile

I, Das ShrikKrishna J. MCA III IMSCD&R, Ahmednagar.

Monday, 15 August 2011

Implement Structure with Functions(2nd Meth)

Write a Program in C to implement Structure with Functions using 2nd Method
#include<stdio.h>
#include<conio.h>
struct student
{
int roll;
char name[50];
};
void fun1(int r,char *n); //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.roll,s1.name);
fun1(s2.roll,s2.name);
getch();
}
void fun1(int r,char *n)
{
printf(" %d \t %s \n",r,n);
}

No comments:

Post a Comment

 
Design by Free WordPress Themes | Bloggerized by Lasantha - Premium Blogger Themes | cheap international calls