Some questions on simple variables and declarations

  1. List the variables in the following program and their types.

    #include 
    
      /*This is an even less simple program */
    int main(int argc, char *argv[])
    {
        int CharVal;
        float F1, f2;
        int f1;
        CharVal = getchar();
        if (CharVal=='a') printf("%s Success\n",argv[1]); 
                     else printf("Failure\n");
        return EXIT_SUCCESS;
    }
    

    The variables are CharVal and f1, which are both of type int, plus F1 and f2, which are both of type float.

  2. Try compiling the program and see if the compiler reacts to it in the way you expect.

    Here is a plain text version of the example for you to compile and run.

    The program should compile and run OK. F1 and f1 are distinct, since C is case sensitive when identifying variables.

Answers to these questions.
Back to the note on variables