Program to find ASCII value of any character/number in C & C++

Program to find ASCII value of any character/number in C

code:-

#include <stdio.h>
int main()
{
    char c;
    printf("Enter a character: ");
 
    scanf("%c", &c);
    printf("ASCII value of %c = %d", c, c);
 

}


Console Screen

Input:-4
Output:-52

Program to find ASCII value of any character/number in C++

#include <iostream>
using namespace std;
int main()
{
 char c;
 cout << "Enter a character: ";
 cin >> c;
 cout << "ASCII Value of " << c << " is " << int(c);
 return 0;

}


Console screen
Input:- k
Output:- 107

Latest
Next Post
Related Posts

0 comments: