1.6 Programming Examples
Problem 1
We read about the ASCII character set, print your desired character ASCII values from A to Z.
Solution :
#include<iostream>
using namespace std;
int main ()
{
char a;
cout << "Enter your desired character to print its value: ";
cin >> a;
cout << "According to ASCII character set, value of " << a <<" is :  " << (int)a;
return 0;
}
Output :
When you will execute this program, a console screen will pop up with this text:
Enter your desired character to print its value:
You simply have to type your desired alphabet to print its value. Let's say you want to print the value of “G”. Simply type “G” and press “Enter” key. Your program will print the value of “G” according to ASCII character set. It will, somehow, look like this:
According to ASCII character set, value of "G" is : 71
Problem 2
Write a program in C++ that uses five output statements to print the pattern shown below.
A
AA
AAA
AAAA
AAAAA
Solution :
#include <iostream>
using namespace std;
int main()
{
cout << "A"<< endl;
cout << "AA"<< endl;
cout << "AAA"<< endl;
cout << "AAAA"<< endl;
cout << "AAAAA";
return 0;
}