Question

In: Computer Science

Write a C program, char.c, which prints the numerical value of the special character constants given...

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().

Solutions

Expert Solution

#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


Related Solutions

Write a menu driven C++ program that prints the day number of the year , given...
Write a menu driven C++ program that prints the day number of the year , given the date in the form of month-day-year. For example , if the input is 1-1-2006 , then the day number is 1. If the input is 12-25- 2006 , the day number is 359. The program should check for a leap year. A year is leap if it is divisible by 4 but not divisible by 100. For example , 1992 , and 2008...
(C++) Write a program that prints a table in the following format given a "x" read...
(C++) Write a program that prints a table in the following format given a "x" read from the keyboard. For example, if x is 4, it prints out 0 0 1 1 2 4 3 9 4 16 To avoid mismatch, put 8 white spaces between two numbers.
Write a C++ program that prints a calendar for a given year. ONLY USING "#include<iostream>" and...
Write a C++ program that prints a calendar for a given year. ONLY USING "#include<iostream>" and "#include<cmath>" The program prompts the user for two inputs:       1) The year for which you are generating the calendar.       2) The day of the week that January first is on, you will use the following notation to set the day of the week:       0 Sunday                     1 Monday                   2 Tuesday                   3 Wednesday       4 Thursday                 5 Friday                      6 Saturday Your program should...
Write a C program that, given a file named Program_2.dat as input, determines and prints the...
Write a C program that, given a file named Program_2.dat as input, determines and prints the following information: The number of characters in the file. The number of uppercase letters in the file. The number of lowercase letters in the file. The number of words in the file. The number of lines in the file. Your program should assume that the input file, Program_2.dat, may contain any text whatsoever, and that text might be, or might not be, the excerpt...
With C code Write a switch statement (not a complete program) which prints an appropriate message...
With C code Write a switch statement (not a complete program) which prints an appropriate message for a letter code entered. Use the following messages: If L is entered, output the message "Lakers" If C is entered, output the message "Clippers" If W is entered, output the message "Warriors" If any other character is entered, output the message "invalid code" Make sure to handle the case where the user enters in a small letter. That is, a capital or small...
Write a C program which prints the environment variables to a file "sample.txt" . All variables...
Write a C program which prints the environment variables to a file "sample.txt" . All variables are followed by a newline character. example: example: inputs: envp/environ = {"E1=5","E2=9",NULL} outputs: env.txt as a string would be "E1=5\nE2=9\n".
Using c# , Write a program using a switch statement that takes one character value from...
Using c# , Write a program using a switch statement that takes one character value from the user and checks whether the entered value is an arithmetic operator (+, -, * , /) If not the program display a message that it not of the operators ( (+, -, * , /) .
Programming in C++ Write a program that prints the values in an array and the addresses...
Programming in C++ Write a program that prints the values in an array and the addresses of the array’s elements using four different techniques, as follows: Array index notation using array name Pointer/offset notation using array name Array index notation using a pointer Pointer/offset notation using a pointer Learning Objectives In this assignment, you will: Use functions with array and pointer arguments Use indexing and offset notations to access arrays Requirements Your code must use these eight functions, using these...
Write a C++ program which prints consecutive dates to the console window starting at January 1,...
Write a C++ program which prints consecutive dates to the console window starting at January 1, 2000, as follows. Saturday, January 1, 2000 Sunday, January 2, 2000 Monday, January 3, 2000 Tuesday, January 4, 2000 ... You will define a function which prints the dates indefinitely, exactly as given above, or prints a specific number of dates. For example, if your function prints 7,581 days the result would look like this. Saturday, January 1, 2000 Sunday, January 2, 2000 ......
C program, please Write a program that reads a sequence of 10 integer inputs and prints...
C program, please Write a program that reads a sequence of 10 integer inputs and prints the smallest and largest of the inputs and the number of even and odd inputs. for a beginner please, you could use a while loop,if-else,
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT