Tuesday 24 June 2014

C++ program to print ASCII values of characters in a string


Here is a C++ program to print ASCII values of characters in a string


 SOURCE CODE OUTPUT
#include<iostream>
#include<conio.h>
using namespace std;
int main()
{
    char str[20];
    cout<<"Enter the string : ";
    cin>>str;
    cout<<"Character   ASCII VALUE"<<endl;
    for(int i=0;str[i]!='\0';i++)
        cout<<str[i]<<"\t    "<<int(str[i])<<endl;
    return 0;
}

Any questions regarding to program please write in comments.

No comments:

Post a Comment