Input
ASCII value of each character are :
Output
w = 199
e = 101
l = 108
c = 99
o = 111
m = 109
e = 101
1. Enter a string
2. for(int i=0; i<strlen(str); i++) {
printf(" %c = %d\n",str[i],str[i]); }
/* Print all letters with their ASCII value */
#include<stdio.h>
#include<string.h>
int main()
{
char str[] = {"welcome"};
printf(" ASCII value of each character are : \n");
for(int i=0;i<strlen(str);i++)
printf(" %c = %d\n",str[i],str[i]);
return 0;
}
/* Print all letters with their ASCII value */
#include<iostream>
#include<cstring>
using namespace std;
int main()
{
char str[] = {"welcome"};
cout<<" ASCII value of each character are : "<<endl;
for(int i=0;i<strlen(str);i++)
cout<<" "<<str[i]<<" = "<<int(str[i])<<endl;
return 0;
}
ASCII value of each character are :
w = 199
e = 101
l = 108
c = 99
o = 111
m = 109
e = 101
advertisment