3ARRSTRC - printf("Enter the customer id which is to...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
#include<stdio.h> # #define max 5 # struct customer { int cid; char name[30]; }; } void main() { struct customer *s[max],*p; int choice,count=-1,flag=0,i,y=0; clrscr(); printf("Enter the choice \n1-Add\n2-Delete\n3-Modify\n4-Display\n0-Exit\n"); scanf("%d",&choice); do{ switch(choice) { case 0:{break;} case 1:{ //add if(count<(max-1)) { p=(struct customer *)malloc(sizeof(*p)); printf("\nEnter The customer ID:"); scanf("%d",&p->cid); printf("\nEnter The customer NAME:"); scanf("%s",p->name); for(i=0;i<=count;i++) { if(p->cid==s[i]->cid) { printf("\nThe customer id already exists"); flag=1; break; } } if(flag==0) { count++; s[count]=p; } } else{ printf("Array is full");} break; } case 2:{ //delete printf("Enter the customer id to be deleted"); scanf("%d",&p->cid); for(i=0;i<=count;i++)
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
{ if(p->cid==s[i]->cid) { printf("\nThe customer details are \n"); printf("Id:%d\n",s[i]->cid); printf("Name:%s\n",s[i]->name); while(i<count) { s[i]=s[i+1]; i++; } count--; y=1; break; } } if(y==0) { printf("\nThe customer id does not exist"); } break; } case 3:{//modify
Background image of page 2
Background image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: printf("Enter the customer id which is to be modified"); scanf("%d",&p->cid); for(i=0;i<=count;i++) { if(p->cid==s[i]->cid) { printf("\nThe customer details are \n"); printf("Id:%d\n",s[i]->cid); printf("Name:%s\n",s[i]->name); printf("\nEnter The new customer NAME:"); scanf("%s",p->name); s[i]=p; y=1; break; } } if(y==0) { printf("\nThe customer id does not exist"); } break; } case 4:{//display printf("Enter the customer id to be displayed"); scanf("%d",&p->cid); for(i=0;i<=count;i++) { if(p->cid==s[i]->cid) { printf("\nThe customer details are \n"); printf("Id:%d\n",s[i]->cid); printf("Name:%s\n",s[i]->name); y=1; break; } } if(y==0) { printf("\nThe customer id does not exist"); } break; } default:{printf("\nInvalid CHOICE");} } printf("count:%d",count); printf("Enter the choice \n1-Add 2-Delete 3-Modify 4-Display 0-Exit\n"); scanf("%d",&choice); }while(choice!=0); getch(); }...
View Full Document

This note was uploaded on 10/25/2010 for the course CMPN SEM3 taught by Professor Thakur during the Fall '07 term at University of Mumbai.

Page1 / 3

3ARRSTRC - printf("Enter the customer id which is to...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online