In: Computer Science
Write a C program, char.c, which prints the numerical value of
the special character constants given below. Don’t just look up the
codes and print them directly from your program. You should have
your program output the values of the character constants by using
them as string literals within your printf() statements.
Your output should be presented in a neat, orderly, tabular format
as shown below:
Char Constant Description Value '\n' newline '\t' horizontal tab
'\v' vertical tab '\b' backspace '\r' carriage return '\f' form
feed '\\' backslash '\'' single quote (apostrophe) '\"' double
quote '\0' null
Use the following guidelines to develop your program:
Declare your variables with appropriate data types.
Assign values to your variables.
Perform your calculations.
Generate appropriate output.
Points to Remember: Make sure you are creating a C program and not
a C++ program. The .c suffix to your source code will invoke the C
compiler while the .cpp suffix will invoke the C++ compiler. As
this is a class in C and not C++, please make sure your source code
uses the .c suffix. You should not be using any global variables in
your program. A global variable is a variable declared outside of
main().
Output from your program should be sent to the terminal window
(your screen) as well as the requested csis.txt output file. Be
sure to read the document on Capturing Program Output. Your full
name and Palomar ID number must appear as a comment in the source
file that contains main().
#include <stdio.h>
int main()
{
const char backspace='\b';
const char newline ='\n';
const char horizontal_tab='\t';
const char vertical_tab='\v';
const char carriage_return='\r';
const char form_feed='\f';
const char backslash='\\';
const char single_quote='\'';
const char double_quote='\"';
const char null='\0';
printf("'\\b' backspace numerical value is %d\n",backspace);
printf("'\\n' newline numerical value is %d\n",newline);
printf("'\\t' horizontal_tab numerical value is
%d\n",horizontal_tab);
printf("'\\v' vertical_tab numerical value is
%d\n",vertical_tab);
printf("'\\r' carriage_return numerical value is
%d\n",carriage_return);
printf("'\\f' form_feed numerical value is %d\n",form_feed);
printf("'\\\\' backslash numerical value is %d\n",backslash);
printf("'\\'' single_quote numerical value is
%d\n",single_quote);
printf("'\\\"' double_quote numerical value is
%d\n",double_quote);
printf("'\\0' null numerical value is %d\n",null);
}
Output-
Please comment for further information