market program please help

This is a discussion on market program please help within the C Programming forums, part of the General Programming Boards category; Code: #include <stdio.h> #include <stdlib.h> #include <conio.h> int main(){ char choice,shopping=1; int x,sugar=350,jam=250,shampoo=199,bread=50 ,eggs=90,subtotal1=0,subtotal2=0,subtotal3=0,subtotal4=0,subtotal5=0,total; while(shopping) {printf("WELCOME TO NUST DHABBA\n"); printf("World's ...

  1. #1
    Registered User
    Join Date
    Nov 2011
    Posts
    64

    market program please help

    Code:
    #include <stdio.h>
    #include <stdlib.h>
    #include <conio.h>
    
    int main(){
    char choice,shopping=1;
    int x,sugar=350,jam=250,shampoo=199,bread=50 ,eggs=90,subtotal1=0,subtotal2=0,subtotal3=0,subtotal4=0,subtotal5=0,total;
    
    while(shopping)
    {printf("WELCOME TO NUST DHABBA\n");
    printf("World's biggest Departmental store\n");
    printf("Enter choice\n");
    printf("[1] for 1 kg sugar bag\n");
    printf("[2] for Jam\n");
    printf("[3] for XYZ Shampoo\n");
    printf("[4] for Bread\n");
    printf("[5] for 1 dozen eggs\n");
    printf("[q] to quit shoping\n");
    total=subtotal1+subtotal2+subtotal3+subtotal4+subtotal5;
    choice=getch();
    
    if((choice=='q')||(choice=='Q'))
    exit(0);
    
    if(choice=='1') {
    printf("shopped:1 kg sugar bag=350 rupees\n",sugar);
    printf("how many?\n",x);
    scanf("%d",&x);
    subtotal1=sugar*x;
    printf("Sub total:sugar=%d\n",subtotal1);
    getch();
    }
    if(choice=='2'){
    printf("Shopped:Jam=250\n",jam);
    printf("How many?\n",x);
    scanf("%d",&x);
    subtotal2=jam*x;
    printf("Sub total:Jam=%d\n",subtotal2);
    getch ();
    }
    if(choice=='3') {
    
    printf("shopped:XYZ shampoo\n",shampoo);
    printf("How many?\n",x);
    scanf("%d",&x);
    subtotal3=shampoo*x;
    printf("Sub total:shampoo=%d\n",subtotal3);
    getch ();
    }
    if(choice=='4'){
    printf("Shopped:Bread\n",bread);
    printf("How many?\n",x);
    scanf("%d",&x);
    subtotal4=bread*x;
    printf("Sub total:Bread=%d\n",subtotal4);
    
    }
    if(choice=='5') {
    
    printf("shopped:dozen eggs\n",shampoo);
    printf("How many dozens you want?\n",x);
    scanf("%d",&x);
    subtotal5=eggs*x;
    printf("Sub total:eggs=%d\n",subtotal5);
    getch();}
    printf("Do you want to shop more Y/N?\n");
    if ((choice!='y'))
    shopping=1;
    total=subtotal1+subtotal2+subtotal3+subtotal4+subtotal5;
    printf("Total is %d\n",total);
    getch ();
    }
    }
    when the user press 'q' this program prints "do you want to shop more?" but i want that the program always ask itself about shopping more.how to do it?
    moreover,any suggestions to make it more simple and it uses lesser space.
    Last edited by danishzaidi; 11-09-2011 at 02:29 AM.

  2. #2
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,786
    Moved to C board

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. a program for a super market!
    By danishzaidi in forum C Programming
    Replies: 5
    Last Post: 11-09-2011, 11:51 AM
  2. Market Needs
    By Smeagol in forum C++ Programming
    Replies: 14
    Last Post: 05-29-2006, 03:06 PM
  3. All Kind Articles on Job Market (FYI)
    By alphaoide in forum A Brief History of Cprogramming.com
    Replies: 0
    Last Post: 02-02-2005, 12:23 PM
  4. Items with a HOT market
    By holden in forum A Brief History of Cprogramming.com
    Replies: 5
    Last Post: 09-06-2004, 10:27 PM
  5. Stock market
    By Liger86 in forum A Brief History of Cprogramming.com
    Replies: 2
    Last Post: 05-20-2003, 05:12 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21