165k views
4 votes
Retype the statements, correcting the syntax errors.

printf("Num: %d\\", songnum);
printf("%d\\", int songNum);
printf("%d songs\\" songNum);

This activity will perform two tests: the first with songNum = 5, the second with songNum = 9

#include

int main(void) {
int songNum;

songNum = 5;

return 0;
}

1 Answer

4 votes

Answer: Following are the corrected statements as mentioned in question

printf("Num: %d\\", songNum);

printf("%d\\", songNum);

printf("%d songs\\", songNum);

Step-by-step explanation:

  • In the first statement, small n was used as, c is a case-sensitive programming language, so, songnum and songNum are considered different variable names and here songNum was used.
  • In the second one, int was used. While writing printf statement data type is not used. To mention data type %d is used which shows an integer type variable is printed here. So, int has to be removed.
  • In the last one, ',' was missing, which is a part of the syntax for the printf statement.
User Schmmd
by
4.4k points