Structure With Array :
We can create structures with array for ease of operations in case of getting multiple same fields.Program :
/* Program to demonstrate Structure With Array. Creation Date : 23 Nov 2010 06:49:00 PM Author : www.technoexam.com [Technowell, Sangli] */ #include <stdio.h> #include <conio.h> struct emp_info { int emp_id; char nm[50]; }emp[2]; void main() { int i; clrscr(); for(i=0;i<2;i++) { printf("\n\n\t Enter Employee ID : "); scanf("%d",&emp[i].emp_id); printf("\n\n\t Employee Name : "); scanf("%s",emp[i].nm); } for(i=0;i<2;i++) { printf("\n\t Employee ID : %d",emp[i].emp_id); printf("\n\t Employee Name : %s",emp[i].nm); } getch(); }
Output :
Enter Employee ID : 1 Employee Name : ABC Enter Employee ID : 2 Employee Name : XYZ Employee ID : 1 Employee Name : ABC Employee ID : 2 Employee Name : XYZ_






0 comments:
Post a Comment
Dont Forget for Commets