command prompt window disappears before output

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • brianbarr
    New Member
    • Jan 2013
    • 1

    command prompt window disappears before output

    this is my program, it works fine when asking for inputs, but as soon as i press enter for the output the window just dissapers.

    Code:
    #include<stdio.h>
    main()
    {int bno;
     float sv,tax;
    
    clrscr();
     printf("\n\n\t Enter Bill Number:");
     scanf("%d",&bno);
     printf("\n\n\t Enter Sale Value:");
     scanf("%f",&sv);
    
    if(sv<=100000)
      tax=sv*0.09;
      else
       if(sv<=350000)
         tax=(sv-100000)*0.12+9000;
         else
          tax=(sv-350000)*0.15+39000;
    
    clrscr();
     printf("\n\n\t Bill Number:%d",bno);
     printf("\n\n\t For Sales Value Rs.%.2f.",sv);
     printf("\n\n\t Sales Tax Amount Calculation is as follows:");
    
    if(sv<=100000)
      printf("\n\n\t Sales Tax=%.2f*0.09=%.2f",sv,tax);
      else
       if(sv<=350000)
         printf("\n\n\t Sales Tax=(%.2f-100000)*0.12+9000=%.2f",sv,tax);
         else
          printf("\n\n\t Sales Tax=(%.2f-350000)*0.15+39000=%.2f",sv,tax);
     }
    Last edited by Rabbit; Jan 14 '13, 07:47 PM. Reason: Please use code tags when posting code.
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    Please use code tags when posting code.

    Add a line at the end to scan for a final input. So they can choose when to exit by hitting enter.

    Comment

    • leecorp
      New Member
      • Jan 2013
      • 10

      #3
      Just Type in getch();
      At the end of the code Before closing the Program "}"

      Or

      Just Put some Scanf() Code
      For Example

      scanf("%f",&sv) ;

      At the end of the code Before closing the Program "}"

      Then the Screen Wont Exit

      Comment

      Working...