Structure and Pointer

Thursday, 8 September 2011

#include<stdio.h>
#include<conio.h>
 typedef struct
  {
    int icode;
    char iname[10];
    int quan;
    int uprice;
  }item;
void main()
{
item i1;
item *p;
clrscr();
p=&i1;
printf("Enter Item code,Item name,Quan. and Unit Price");
scanf("%d%s%d%d",
                    &p->icode,p->iname,&p->quan,&p->uprice);
printf("\n Item Code=%d\n",i1.icode);
printf("\n Item Name=%s\n",i1.iname);
printf("\n Item Quantity=%d\n",i1.quan);
printf("\n Item Unit price=%d \-\n",i1.uprice);
getch();
}


OUTPUT:


Enter Item code,Item name,Quantity and Unit Price 
101
Monitor
1
250
Item Code=101
Item Name=Monitor
Item Quantity=1
Item Unit Price=250







No comments:

Post a Comment

 

Blogger news

Blogroll

Enter your email address:

Delivered by FeedBurner

Total Pageviews

Followers

Most Reading