Recents in Beach

Printf() in C language for beginners

Printf() in C language for beginners

In this post, we will learn to use printf() and scanf() function in c language .

printf() and scanf() functions are inbuilt library functions in C programming language which are available in C library. Functions printf() and scanf are declared in header file <#includestdio.h> .

We have to include “stdio.h” in our program to use printf and scanf(),In C programming language, printf() function is used to print the (“character, string, float, integer, octal and hexadecimal values”) onto the output screen. We use print() function with %d format specifier to display the value of an integer variable or character. We have basic four format specifier int , float, character, double in c language .We use %c  to display character, %f for float variable, %s for string variable, %lf for double variable.

Example 1:

#include<stdio.h>

Int main()

{

  Printf(“Welcome to launchpadlwd”);

  return 0;

}



Example 2 integer and float :

#include<stdio.h>

Int main()

{

  int a=5;

  float b=6.66;

  Printf(“%d”,a);

  Printf(“\n %d”,b);

  return 0;

}





Example 3 charachter:


#include<stdio.h>

Int main()

{

  char b=’a’;

  Printf(“%c”,b);

  return 0;

}






List Of Format specifiers:

Data Type       Format Specifier

int                         %d

char                      %c

float                      %f

double                 %lf

To Study about C programming Please visit this link:

Post a Comment

0 Comments