You are here:

C++/C++ Problem


 I hope you might be able to help me. My instructor gave us a problem and I have no idea how to really get started. The instructor told us he didn't really know how to do it so I hope you can help me. The problem is to write a simple job to write out a function that calls the Ascii code. It has to print ou the Ascii code upper and lower case letters. I hope you can help me thank you for your time. I use a C++ Compiler.

Hi Deujan.
I have provided the program below.I have used type conversion to obtain ASCII code.When you conver char to int, you getascii code. My variable ascii is int. Variables alphabet and up_alphabet are char. When I san ascii=alphabet or ascii=up_alphabet, ascii receives the ASCII value.
I have put all this in a loop.
When I say alphabet++, it changes to the next alphabet.(if it was 'd' before, it becomes 'e' and so on).

Since all 26 cannot come on one page, I have displayed 13 and 13.

#include <iostream.h>
#include <conio.h>

void main()
char alphabet='a';
char up_alphabet='A';
int ascii;
for(int i=1;i<=26;i++)
  cout<<alphabet<<" : "<<ascii<<"   ";
  cout<<up_alphabet<<" : "<<ascii;
       cout<<"\n\nPress any key to view other 13 codes";



All Answers

Answers by Expert:

Ask Experts


Samarth Bartaria


I can answer questions about pointers behaviour, their implementations and anamolous behaviour.Also, I speciallize in object oriented design and modelling,polymorphism in C++ and algorithm efficiency. Even questions related to database design,or simple basics about programming are welcome.


I have been using C++ for five years now for software development and scientific analyses.

Currently, I am a student doing my computer engineering.

©2016 All rights reserved.