Thread: I can't compile and put it as a variable and matrix

  1. #1
    Registered User
    Join Date
    Nov 2020
    Posts
    4

    I can't compile and put it as a variable and matrix

    Hi!
    I cannot compile this program.
    Please help me because I have no idea how I do it, my teacher spent this activity and I found it very difficult.


    after completing an option, the program must return to the initial menu until "0" is pressed


    Code:
     #include <stdio.h>#include <conio.h>
    
    
    
    
    int main ()
    {
    system ("CLS");
    internal item [8] [5]; // matrix that will store how many items have been released
    int op, wave, i, j;
    float value [8] [5]; // matrix that will store the total value
    float cash = 0; /// variable that will store the cash value
    
    
    
    
    printf ("\ n");
    printf ("| * -------------------- Welcome to the restaurant! ------------------- - * | \ n ");
    printf ("\ n");
    
    
    
    
    // Menu
    printf ("[1] Open table \ n");
    printf ("[2] Launch expenses \ n");
    printf ("[3] Close the table account \ n");
    printf ("[4] Check in the Cashier \ n");
    printf ("[0] Exit \ n");
    printf ("\ n Choose an option:");
    scanf ("%d", & op);
    switch (op)
    // must receive only one character (1,2,3,4,0) without the need to press to enter any other number must be disregarded.
    {
    case 0:
    printf ("\ n \ n Exiting the program \ n \ n");
    break;
    case 1:
    printf ("Enter the table number:");
    scanf ("%d");
    if (item> = - 1) printf ("Table%d open");
    else if (item <= 0)
    printf ("Error, this table is not free. Choose another table!");
     break;
    case 2:
    printf ("\ nValue posted on table \ n");
    printf ("Release quantity:%d");
    scanf ("%d");
    printf ("Total table price: R$");
    scanf ("%f");
    if (table> = - 0) printf ("Table%d open");
    else if (table <= -1)
    printf ("Error, this table is not open!");
    break;
    case 3:
    printf ("The table has just been closed");
    // shows the total value of the table and the number of posted items that are in (case 2)
     break;
    case 4:
    printf ("The total cash value: R $%.2f");
    // the total cash value of all tables seems
    break;
    default:
    printf ("\ n Invalid option! \ n \ n");
    }
    return 0;
    }
    Last edited by Salem; 11-04-2020 at 10:58 PM. Reason: it's [code], not [CÓDIGO]

  2. #2
    Registered User
    Join Date
    Sep 2020
    Posts
    425
    I tried too. I get lots of errors because you have spaces between the '\' and the 'n'.

    With those fixed, it seems most of the time when you try to print a number you put the format string, but not the value you are trying to print.

    Code:
        printf ("Table%d open");
    Should be something like:

    Code:
        printf ("Table %d open", table);
    And the same for where you use scanf().

    You should also post a few of the errors you are seeing, so we get hints for where to look for problems.

  3. #3
    Registered User
    Join Date
    Nov 2020
    Posts
    4
    is that I translated my code to be able to post here the translator placing these spaces between \ and n

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    > is that I translated my code to be able to post here the translator placing these spaces between \ and n
    You should copy the code from your editor, not from some translator.
    It even translated the code tags, which just doesn't work.

    These are wrong as well.
    scanf ("%d");
    printf ("Total table price: R$");
    scanf ("%f");
    if (table> = - 0) printf ("Table%d open");


    Your scanf and printf formats need extra parameters.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  5. #5
    Registered User
    Join Date
    Nov 2020
    Posts
    4
    but what can I do to make it run because I have no idea how to do it.
    Because this matter is very difficult for me.
    I don't know where to move or change for the program to compile.


  6. #6
    Registered User
    Join Date
    Sep 2020
    Posts
    150
    I would suggest that you start learning the syntax of the C language first.
    There are plenty of free tutorials online. Alternatively you could get a book.
    A few were recommended to you in a previous thread:
    I can't do the commands

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Define a const variable at compile time?
    By bedtime in forum C++ Programming
    Replies: 2
    Last Post: 03-10-2019, 01:34 PM
  2. Replies: 2
    Last Post: 05-19-2014, 07:32 PM
  3. Replies: 4
    Last Post: 02-03-2012, 09:58 PM
  4. Replies: 2
    Last Post: 11-22-2010, 06:32 PM
  5. compile error about member variable initialization
    By George2 in forum C++ Programming
    Replies: 4
    Last Post: 12-04-2007, 11:55 AM

Tags for this Thread