C Program to find ASCII Value of All Characters in a String

C Program to find ASCII Value of All Characters in a String

C program to find the ascii value of all characters in a string; Through this tutorial, we will learn how to find the ascii value of all characters in a given string using for loop and while loop.

Programs to find ASCII Value of All Characters in a String in C

  • C Program to find ASCII Value of All Characters in a String using for loop
  • C Program to find ASCII Value of All Characters in a String using while loop

C Program to find ASCII Value of All Characters in a String using for loop

/* C Program to find ASCII Value of Total Characters in a String */
#include <stdio.h>
int main()
{
    char str[100];
    
    printf("\n Please Enter any String  :  ");
    scanf("%s", str);
        
    for( int i = 0; str[i] != '
/* C Program to find ASCII Value of Total Characters in a String */
#include <stdio.h>
int main()
{
char str[100];
printf("\n Please Enter any String  :  ");
scanf("%s", str);
for( int i = 0; str[i] != '\0'; i++)
{
printf(" The ASCII Value of Character %c  = %d \n", str[i], str[i]);
}
return 0;
}
'; i++) { printf(" The ASCII Value of Character %c = %d \n", str[i], str[i]); } return 0; }

The output of the above c program; as follows:

Please Enter any String  :  tutsmake
The ASCII Value of Character t  = 116 
 The ASCII Value of Character u  = 117 
 The ASCII Value of Character t  = 116 
 The ASCII Value of Character s  = 115 
 The ASCII Value of Character m  = 109 
 The ASCII Value of Character a  = 97 
 The ASCII Value of Character k  = 107 
 The ASCII Value of Character e  = 101 

C Program to find ASCII Value of All Characters in a String using while loop

/* C Program to find ASCII Values of Total Characters in a String */
#include <stdio.h>
int main()
{
    char str[100];
    int i = 0;
    
    printf("\n Please Enter any String  :  ");
    scanf("%s", str);
        
    while( str[i] != '
/* C Program to find ASCII Values of Total Characters in a String */
#include <stdio.h>
int main()
{
char str[100];
int i = 0;
printf("\n Please Enter any String  :  ");
scanf("%s", str);
while( str[i] != '\0')
{
printf(" The ASCII Value of Character %c  = %d \n", str[i], str[i]);
i++;
}
return 0;
}
') { printf(" The ASCII Value of Character %c = %d \n", str[i], str[i]); i++; } return 0; }

The output of the above c program; as follows:

Please Enter any String  :  tutsmake
The ASCII Value of Character t  = 116 
 The ASCII Value of Character u  = 117 
 The ASCII Value of Character t  = 116 
 The ASCII Value of Character s  = 115 
 The ASCII Value of Character m  = 109 
 The ASCII Value of Character a  = 97 
 The ASCII Value of Character k  = 107 
 The ASCII Value of Character e  = 101 

Recommended C Programs

AuthorAdmin

My name is Devendra Dode. I am a full-stack developer, entrepreneur, and owner of Tutsmake.com. I like writing tutorials and tips that can help other developers. I share tutorials of PHP, Python, Javascript, JQuery, Laravel, Livewire, Codeigniter, Node JS, Express JS, Vue JS, Angular JS, React Js, MySQL, MongoDB, REST APIs, Windows, Xampp, Linux, Ubuntu, Amazon AWS, Composer, SEO, WordPress, SSL and Bootstrap from a starting stage. As well as demo example.

Leave a Reply

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