In: Computer Science
1. The following program has syntactic errors. Identify the errors and correct them.
Compile the corrected program and submit a screeshot showing that the program has 0 (zero) errors.
You can use https://repl.it/languages/c or https://www.onlinegdb.com/
#include <stdio.h>
int main (Void)
{
INT sum;
/* Compute result
sum = 25 + 37 - 19;
// Display result
printf (“The answer is %i\n”, sum);
return 0;
} // main
2. What is the purpose of a variable?
a. |
To assign values |
|
b. |
To perform calculations |
|
c. |
To hold a value |
|
d. |
To hold a constant value |
Answer
1. Here is the code witn explanation in comments without any errors or bugs
Raw code:
#include <stdio.h>
//changed Void to void
int main (void)
{
//changed INT to int cause there is nothing called INT in C languge
int sum;
// Compute result
sum = 25 + 37 - 19;
// Display result
printf ("The answer is %i\n", sum);
return 0;
}
Editor:
ouptut:
2.
Answer:
a. |
To assign values |
A variable is declared to store the assigned value in it to perform further calculations.
Hope this helps you! If you still have any doubts or queries please feel free to comment in the comment section.
"Please refer to the screenshot of the code to understand the indentation of the code".
Thank you! Do upvote.