C Programming Tutorial – 3 – what can we do with “printf()” ? :

Code:
—————————

#include <stdio.h>
#include <stdlib.h>

int main()
{

  • // Print “Hello world!” on the screen + goes to new line
    printf(“Hello world!\n”);

 

  • // Print “Hi Sajjad” on the screen + insert a tab space
    printf(“Hi Sajjad\t”);

 

  •  // Print “This is a tab test” on the screen + goes to new line + make a alarm sound
    printf(“This is a tab test\n\a”);

 

  • // Conversion string use %s to replace a string
    printf(“%s is an intelligent boy and %s\n” , “SAJJAD”,”programmer”);

 

  • // Conversion integer use %d to replace a integer number
    printf(“I ate %d eggs last morning\n”,2);

 

  •  // Conversion decimal use %f to replace a decimal number
    printf(“my weight is %f\n”, 80.467896212);

 

  •  // Conversion decimal use %.4f to replace a decimal number with 4 decimal number
    printf(“my weight is %.4f\n”, 80.467896212);

 

  • // Conversion decimal use %.2f to replace a decimal number with 2 decimal number
    printf(“my weight is %.2f\n”, 80.467896212);

return 0;

}