Home » , » Basic C Programming Practice - Practice 21

Basic C Programming Practice - Practice 21

Written By Unknown on Thursday, October 10, 2013 | 11:57 PM

=> Write a program in C to read and print a given character?




Solution :

                        #include<stdio.h>
                        #include<conio.h>

                          main()

                              {

                               char ch;

                               printf("Please Enter Your Character : ");

                               scanf("%c",&ch);

                               printf("%c",ch);

                               getch();

                               }

Program Analysis :
As we are working with character here, that's why we used character data type "char" and a character variable "ch"

This program is very simple and basic because the requirement is just to get input and print that same input so,
First we get input from terminal : scanf("%c",&ch);

Then we just print the value : printf("%c",ch);

We use %c for character type variable to get input and print output to the screen.
Share this article :

Post a Comment

 
Support : Creating Website | Johny Template | Mas Template
Copyright © 2011. Learn Programming - All Rights Reserved
Template Created by Creating Website Published by Mas Template
Proudly powered by Blogger| Distributed by Rocking Templates