|
Get 9,000+ Interview Questions with Answers in an eBook
C Source Codes List | Source Code Home
Program : Program to print the ascii equivalent of all chararters in the entered string.
/* Prg. to print the ascii equivalent of all chararters in the entered
string */
#include
#include
#include
int ascii_value(char c);
void main()
{
int i,a;
char c;
clrscr();
printf("Please enter a string.");
printf("\nString will be terminated if you press Ctrl-Z.");
printf("\nSTRING:- ");
for (i=0;(c=getchar())!=EOF;i++)
{
a=ascii_value(c);
printf("%d%c",a,' ');
}
printf("\n\t are the ascii values of the characters of the entered string");
printf("\n\t respectively.");
printf("\n\n\n\n\n\t\t\tHAVE A NICE DAY! BYE.");
getch();
}
int ascii_value(char c)
{
int a;
a=(int)c;
return(a);
}
C Source Codes List | Source Code Home
|
|
|