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

Greetings, I'm Devendra Dode, a full-stack developer, entrepreneur, and the proud owner of Tutsmake.com. My passion lies in crafting informative tutorials and offering valuable tips to assist fellow developers on their coding journey. Within my content, I cover a spectrum of technologies, including 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. Whether you're starting out or looking for advanced examples, I provide step-by-step guides and practical demonstrations to make your learning experience seamless. Let's explore the diverse realms of coding together.

Leave a Reply

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