Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

DEMO: SIMPLE CHARACTER INPUT AND OUTPUT USING getchar AND Putchar FUNCTIONS PROG

ID: 3798494 • Letter: D

Question

DEMO: SIMPLE CHARACTER INPUT AND OUTPUT USING getchar AND Putchar FUNCTIONS PROGRAM DESCRIPTION This program reads a character from the keyboard, computes a new character, and prints the results to the computer screen. DESCRIPTION OF VARIABLES: I YPE I DESCRIPTION any character I char I a character enter from the keyboard new character I int I calculation of new character Preprocessor directives Einclude Sinclude cctype.h> Main function int nain (void) Declare variables char any character: int new character Get character from the keyboard print printf ("VnEnter a character from the keyboard: Print character printf ("IninThe character entered is printf( InThe ASCII integer value of the character is x-3i any character); Compute new character new character 7 any character; Print new character print ASCII integer value of the new character is -3i new character); printf ("InThe new character is ")i print in................................................ Exit the program return

Explanation / Answer

#include <stdio.h>
#include <math.h>
#include <ctype.h>

int main(void)
{

char any_character;
int new_character;

/*Get character from the keyboard */
printf("********************************************************");
printf(" Enter the character from the keyboard: ");
any_character = (char)getchar(); //Use of Typecasting to match the syntax

/*Print character */
printf(" The character entered is ");
putchar((int)any_character); //Use of Typecasting to match the syntax
printf(" The ASCII integer value of the character is %+3i",any_character);


/*Compute new character*/
new_character = 7+any_character;

/*Print new character*/
printf(" The ASCII integer value of the new character is %+3i",new_character);

printf(" The new character is ");
putchar(new_character);

printf(" ********************************************************************* ");

/*Exit the program */
return 0;

}
/**********************************************************************************************/



}