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

Write a program called, A1Q1, that reads a single letter. It will then display t

ID: 3622853 • Letter: W

Question

Write a program called, A1Q1, that reads a single letter. It will then display the
corresponding ASCII code of the letter and prints the next character and the character which
is corresponding to the “ASCII code + 3”. Comment on the unusual behaviour if you enter 'z'
or 'Z' or '9' or '@'. Shorthand operators and increment/decrement operators should be used in
your code.

Here is a sample run:
Enter your initial: J <Enter>
The ASCII code of J is 74
The next character is K
The third character is M

Explanation / Answer

please rate - thanks

C++

#include <iostream>
using namespace std;
int main()
{char init;
cout<<"Enter your initial: ";
cin>>init;
cout<<"The ascii code of "<<init<<" is "<<(int)init<<endl;
if(init=='Z'||init=='z')
     cout<<"This is the last letter of the alphabet ";
init++;
cout<<"The next character is: "<<init<<endl;
init+=2;
cout<<"The third character is: "<<init<<endl;
system("pause");
return 0;
}

C

#include <stdio.h>
#include<conio.h>
int main()
{char init;
printf("Enter your initial: ");
scanf("%c",&init);
printf("The ascii code of %c is %d ",init,(int)init);
if(init=='Z'||init=='z')
     printf("This is the last letter of the alphabet ");
init++;
printf("The next character is: %c ",init);
init+=2;
printf("The third character is: %c ",init);
getch();
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