C Programming Examples Tutorial Index

C Loop Programs

This C program is used to find and print the ASCII value of a letters, numbers, and other characters.



Each character or number has its own ASCII value.

Example:

The ASCII value of the number '5' is 53 and for the letter 'A' is 65.

Program:

/* 
* File: ascii.c
* Author: Gautam
* Created on August 17, 2017, 4:00 PM
*/ 

#include <stdio.h>

int main(){
        char c = 'w';
        printf("ASCII value of %c is %d\n", c, c);
        return 0;
}

Program Output:

ASCII value of w is 119

Program:

/* 
* File: ascii.c
* Author: Gautam
* Created on August 17, 2017, 4:00 PM
*/ 

#include <stdio.h>

int main(){
        char c;
        printf("Please enter a character: ");
        scanf("%c", &c); 
        printf("ASCII value of %c is %d\n", c, c);
        return 0;
}

Program Output:

Please enter a character: g
ASCII value of G is 103


Found This Page Useful? Share It!
Get the Latest Tutorials and Updates
Join us on Telegram