C C++ program to find ASCII value of a character

 

Coding in C

#include<stdio.h>
int main()
{
char ch;
int val;
printf(“Enter a character: “);
scanf(“%c”,&ch);
val=ch;
printf(“ASCII value = %d”,val);
return 0;
}

 

Coding in C++

#include<iostream>
using namespace std;
int main()
{
char ch;
int val;
cout<<“Enter a character: “;
cin>>ch;
val=ch;
cout<<“ASCII value = “<<val;
return 0;
}

 

Output

ASCII Value of a Character Program Output

 

Published by

admin

I am a computer teacher, programmer and web developer