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

Write a program that declares a character array that is able to hold 5 chars. In

ID: 674377 • Letter: W

Question

Write a program that declares a character array that is able to hold 5 chars. Initialize the array to contain all blank spaces initially. Prompt the user to enter 5 single keystrokes at the keyboard and store the character result in a corresponding spot in the array. You must use the %c conversion code in conjunction with scanf() when doing this. Demonstrate both techniques used to cleanse the keyboard buffer of phantom enter keys after the scanf() statements run (absorb the enter key and flush the buffer). After that, display a neatly organized table that contains the decimal representation of the characters entered, the ASCII code for the characters entered, and the memory location of the spot in the array where each element sits in memory. You may ignore warnings that indicate a conflict between the %x conversion character and (char*). Feel free to issue the necessary #pragma directive to remove the warning if you desire. You should begin your program with the following shell:HELPP

Explanation / Answer

#include <stdio.h>


int main(){


char arr[5];
int i;
for(i=0;i<5;i++){
arr[i]=' ';
}
printf("Enter the characters: ");
for(i=0;i<5;i++){
scanf("%c",&arr[i]);
}
char c=getchar();
printf("CHARACTER ACII VALUE ");
for(i=0;i<5;i++){
printf("%c %d ",arr[i],arr[i]);
}
return 0;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote