ProAnswers.org

Write a C program to read a name through keyboard. Determine length of the string and find its equivalent ASCII codes?

#include

#include 

#include 

void main() 

{ 

static char name[20]; 

int i,l; 

clrscr(); 

printf(“enter your name:”); 

scanf(“%s”, name); 

l=strlen(name); 

printf(“your name is %s & ”, name); 

printf(“it contains %d characters”, l); 

printf(“

Name & its ASCII Equivalent
”);

printf(“= = = = = = = = = = = = = = = 

”);

for(i=0;i<1;i++) 

printf(“

%c %d”, name[i]name[j]);

getche(); 

} 

Output: 

Enter your name: SACHIN 

Your name is SACHIN & it contains 6 characters 

Name& its ASCII equivalent 

= = = = = = = = = = = = = = = 

S 83 

A 65 

C 67 

H 72 

I 73 

N 78