C Program to find the ASCII Value of All Character

In this tutorial, i am going to show you how to find the ascii value of all character in c program.

All C Programs to find ASCII value of all Characters

  • C Program to find ASCII value of all Characters using For Loop
  • C Program to find ASCII value of all Characters using While Loop

C Program to find ASCII value of all Characters using For Loop

#include <stdio.h>
int main()
{
  int i;
  
  for(i=0;i<=255;i++)
   {
    printf("The ASCII value of %c = %d\n",i,i);
   }
  return 0;
}

C Program to find ASCII value of all Characters using While Loop

#include <stdio.h> 
#include <string.h> 
void main()
{
 int i = 0, sum = 0;
 char name[50];
 
 printf("\nPlease Enter any name You wish\n");
 scanf("%s", name);
 while(name[i]!='\0')
  {
   printf("The ASCII value of the Character %c = %d\n",
   name [i], name [i]);
   sum = sum + name [i];
   i++;
  }
 printf("\nSum of all characters : %d ", sum);
}

The result of the above c program; as follows:

Please Enter any name You wish :- d

The ASCII value of the Character d = 100

Sum of all characters : 100 

More C Programming Tutorials

Be First to Comment

Leave a Reply

Your email address will not be published. Required fields are marked *