C program to find the ASCII value of all character; Through this tutorial, we will learn how to find the ascii value of all character.
Programs to find ASCII value of all Characters in C
- 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]!='#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);
}
')
{
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 output 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