C Mistakes – printf



1 : Missing Comma .

  • Comma is missing between format specifier(“%d”) and Variable (number).
  • Error message : ” Function call missing )
#include<stdio.h>
void main()
{
int number = 10;
printf("%d"number);
        //Error it should be written as : printf("%d",number);
}

2 : Write Correct Spelling of printf.

  • By mistake , many beginners misspelled “printf” as “print”.

3 : Check for Cases

  • C Programming is known as “Case Sensitive Language “.
  • “printf” should be written in small case [Lowercase]

4 : Format specifiers and Variable names should appear in Order

.

#include<stdio.h>
void main()
{
int number1 = 10;
float number2 = 3.14;
printf("%d %f",number2,number1);
}
  • Here “%d” is written first so “number1” should be written immediately after Comma.
  • Check for type i.e “%d” is written for “integer” and “%f” for “float”.