C Tutorial
C Programming language supports some special backslash character constants that are used in output functions.
Example '\n' is one of the escape character and used to specify new line character in output functions.
Although escape characters contains two characters that represents single character, the combination is also called as escape sequences.
Escape sequence | Description |
---|---|
\a | audio alert (bell sounds) |
\b | back space character |
\f | form feed character |
\n | new line character |
\r | carriage return character |
\t | horizontal tab character |
\v | vertical tab character |
\' | single quote character |
\" | double quote character |
\? | question mark character |
\\ | backslash character |
\0 | null |
This c program is used to format string the printf function with new line characters.
Example c program finds the character is letter, digit or not alphanumeric character and prints the corresponding string formatted using new line character.
'\t' is used to provide horizantal tab character in the printing string.
#include<stdio.h> #include<ctype.h> void main() { char character; printf("Enter any character: "); character = getchar(); if(isalpha(character) > 0) { printf("Character is\tletter\n\n"); } else if(isdigit(character) >0) { printf("Character is\ta digit\n\n"); } else { printf("Character is\tnot alphanumeric\n\n"); } }
Output:
$ cc character-type.c $ ./a.out Enter any character: r Character is letter $ ./a.out Enter any character: 3 Character is a digit
C Tutorial
Privacy Policy | Copyright2020 - All Rights Reserved. | Contact us
| Report website issues in Github
| Facebook page
| Google+ page