• General form of printf is printf(“<format string>”,< variables which you give>);
  • This <format string> is used to print the values of the variables in out put.

Some of them are :

  • Float :
    %f is its symbol and used for printing real values .
  • Integer :
    %d is its symbol and used for printing integer values.
  • Character :
    %c is its symbol and used for printing character values.

C Instructions :

  • we have to write a statement to declare the type variables we used in the program.
  • This statement should be written at the beginning of main() function.
  • Mainly these are of three types :

    Int :
    It is for integers. Ex:- int a,b ; int bas, ad.
    Float :
    It is for real values. Ex:- float kot, area.
    It is for charecters .ex:- char name,code.

Simple example on above topic

Input is

#include <<stdio.h> #include<conio.h> void main() { clrscr(); int a = 7; float k =14.6; printf("you have entered a=%d”,a ); printf(“\n”); printf(“you have entered k =%d” ,k); getch(); }

Output is:

  • You have entered a=7
  • You have entered k =14.6
Note :-
\n - is used to end the line.
HTML Comment Box is loading comments...