HOME

Friday, March 24, 2017

Shoes Store Sample program using C language !

#include<stdio.h>
#include<conio.h>
void main()
{
    int a[100],i,n,value,loc1,loc2,counter;
    char ch;
    printf("Enter the Quantity of Shoes\n");
    scanf("%d",&n);
    printf("Enter the shoes to put in store\n");
    for(i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
    }
    printf("The Shoes Available in store are\n");
    for(i=0;i<n;i++)
    {
        printf("%d\n",a[i]);
    }
    do{
            counter=0;
    loc1=0;
    loc2=0;
    printf("Enter the shoes you want to buy\n");
    scanf("%d",&value);
    for(i=0;i<n;i++)
    {
        if(value==a[i])
        {
            counter++;
            if(counter==1)
            {
             loc1=i;
            }
            else if(counter==2)
            {
                loc2=i;
            }
        }

    }
    if(counter>=2)
    {
        n--;
        for(i=loc1;i<n;i++)
        {
            a[i]=a[i+1];
        }
        n--;
        loc2--;
        for(i=loc2;i<n;i++)
        {
            a[i]=a[i+1];
        }
        printf("\nYou bought Shoes Successfully\n");
    }
    else if(counter==1)
    {
        printf("\nShoes is not available in pairs");
    }
    else
    {
        printf("\nShoes is out of Stock\n");
    }
    printf("\nNow Available shoes are\n");
    for(i=0;i<n;i++)
    {
        printf("%d\n",a[i]);
    }
    printf("To Buy more shoes Press 'y' or Any key to Terminate\n");
    ch=getch();
    }while(ch=='y' || ch=='Y');
}

No comments:

Post a Comment