C – Unformatted Output Functions

You must first complete Read values in C- scanf() function before viewing this Lesson

C – Unformatted Output Functions

Unformatted output functions provided by C are :

 1. putchar() function in |C

This function is used to display value of a character variable or constant. The header file required is <stdio.h>.

Syntax:

putchar(var);

var refers to the character variable or character constant whose value we want to display using putchar() function.

Program to demonstrate putchar()
#include<stdio.h>
int main()
{
 char n='K'; 
 printf("\ncharacter=");
 putchar(n);
 return (0);
}
Output
character=K

2. putch() function in C

It is also used to display value of a character variable or constant. The header file required for this function is <conio.h>.

Syntax:

putch(var);

var refers to the character variable or character constant whose value we want to display using putch() function.

Program to demonstrate putch()
#include<stdio.h>
#include<conio.h>
int main()
{
 char n='K';
 printf("\ncharacter=");
 putch(n);
 return (0);
}
Output
character=K

3. puts() function in C

It is used to display the value of a string variable or string constant on the screen. The header file required for this function is <stdio.h>.

Syntax:

puts(var);

var refers to the string variable or string constant whose value we want to display using puts() function.

Program to demonstrate puts()

#include<stdio.h>
int main()
{
 char sname[20]="Amit";
 puts(“\nName is”);
 puts(sname);
 return (0);
}
Output
Name is
Amit


Spread the love
Lesson tags: putch function of c, putchar function of c, puts function of c, Unformatted Output Functions in C
Back to: C Programming Language
Spread the love