Home » , , » Fundamental Data Type - Character Type Variable

Fundamental Data Type - Character Type Variable

Written By Unknown on Monday, October 7, 2013 | 11:02 AM

Character Type Variable :
We use character in C - Program to declare the variable as a character type variable.If we declare any variable as a character then C Compiler allow 1 byte memory for that variable.

EX :  Char ch;

here ch is declared as a character type variable and ch will get 1 byte memory.The highest value of character type variable is +127 and the lowest value is -128 according to ASCII.

Watch the program carefully :

#include<stdio.h>
#include<conio.h>
main()
{
char ch1,ch2;
clrscr();
ch1='1';
ch2=1;
printf("ch1 is %c",ch1);
printf("\n ch2 is %c",ch2);
getch();
}

OUTPUT :

ch1 is 1
ch2 is 1

Program Analysis :

->char ch1,ch2;
here ch1and ch2 is two individual character type variable,

->ch1='1'
If we need to keep a character into a character type variable then we must keep it into a single quote ( ' ' )
-> %c
If we need to print any character type variable on our computer screen then we must use %c
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