Click here to Skip to main content
15,890,438 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
/tmp/Cj8Pv0jRVQ.o
sh: 1: cls: not found
computer
=======================

[1] HP Pavilion		php 3,500.00
[2] ChromeBook		php 2,500.00
[3] Acer Aspire		php 4,500.00
[4] HP Ram 16GB		php 500.00
[5] chromeBook Ram 32GB		php 750.00
[6] Acer Ram 64GB		php 1,500.00

Enter Code	: 


What I have tried:

// ASDIGNMENT 1
#include <stdio.h>

void main (void)  {
    int code, qty;
    float price, amt, totalAmt, cash, change;
    char addAnother;
    
    // do-while loop -> post-test
    // while loop -> pre-test
    // for loop -> pretest
    
 do {
    system("cls");
    printf("======================\n");
    printf("computer\n");
    printf("=======================\n\n");
    printf("[1] HP Pavilion\t\tphp 3,500.00\n");
    printf("[2] ChromeBook\t\tphp 2,500.00\n");
	printf("[3] Acer Aspire\t\tphp 4,500.00\n");
    printf("[4] HP Ram 16GB\t\tphp 500.00\n");
	printf("[5] chromeBook Ram 32GB\t\tphp 750.00\n");
	printf("[6] Acer Ram 64GB\t\tphp 1,500.00\n");
    
    printf("\nEnter Code\t: ");
    scanf("%d", &code);
    printf("nEnter Quantity\t:");
    scanf("%d", &qty);
    
    switch(code) {
        case 1: price = 3500.00;
                break;
        case 2: price = 2500.00;
                break;
	    case 3: price = 4500.00;
		        break;
        case 4: price = 500.00;
                break;
		case 5: price = 750.00;
		        break;
		case 6: price = 1500.00;
    }
    amt = price * qty;
    printf("\nAmount\t\t: %.2f", amt); 
    
    totalAmt = totalAmt + amt;
    printf("\nTotalAmount\t: %.2f", totalAmt);
    
    printf("\nAdd another oder(y/n)? ");
    addAnother = getchar();
	addAnother = tolower( addAnother );
    }while(addAnother == 'y' || addAnother == 'Y');
    
    do{
        printf("\nCash Tendered\t: ");
    scanf("%f", &cash);
    }while(cash < totalAmt);
        
    
    change = cash - totalAmt;
    printf("\nChange\t\t: %.2f", change);
    
}
Posted
Updated 26-Sep-22 19:18pm
Comments
Sandeep Mewara 26-Sep-22 22:55pm    
Seems: Repost/Duplicate - https://www.codeproject.com/Questions/5343174/How-to-fix-sh-1-cls-not-found

1 solution

CLS is a DOS command, it will only work under (some) windows environments - and then only is the system function has not been disabled as it has been in online compilers like OnlineGDB.

You can try this:
C
printf("\e[1;1H\e[2J");
which will work if your console supports ANSI sequences (some do, some don't)

If that doesn't work, check the compiler documentation for your specific environment.
 
Share this answer
 
Comments
CPallini 27-Sep-22 1:57am    
5.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900