Writing a Character

The following functions are used to display a character to the screen.

Putchar ()

Single characters can be displayed to the screen using putchar (). The putchar () takes the following form:

putchar(var_name);

Where var _ name is a valid char type variable. For example:

char c = ‘A’;
putchar(c);

This will display the value of c that is character ‘A’ on the screen.

char c;putchar (‘X’);

This will display the alphabet X on the screen.


Program- Use of putchar () function
#include <stdio.h>
void main ()
{
    char ch;
    printf (“\nEnter a character:”);
    ch = getchar ();
    printf (“Entered character is:”);
    putchar (ch);
}

Output

Enter a character: a
Entered character is: a


Putch ()

putch () is similar to putchar (). For example:

char c= ‘A’;
putch (c);

This will display the value of c that is character ‘A’ on the screen.



About the Author



Silan Software is one of the India's leading provider of offline & online training for Java, Python, AI (Machine Learning, Deep Learning), Data Science, Software Development & many more emerging Technologies.

We provide Academic Training || Industrial Training || Corporate Training || Internship || Java || Python || AI using Python || Data Science etc





 PreviousNext