i was asked a question in c programming language : i should ask the user to inte
ID: 3667079 • Letter: I
Question
i was asked a question in c programming language :
i should ask the user to inter words then press inter after every single word and stop we he types "end"
then i should compine all the words in one single string and remove any number he intered then print the clean words string on the shell .
the compined string should only contain words and no numbers at all
if the user inputs more than 50 characters (the sum of characters in all inputs compind together) i should stop and print the compind string for him
the string should be no more than 50 characters
Explanation / Answer
This below c program will read the words up to 50 charecters and remove numbers and any other symobls from the words and print the all the words together..
See the code below:
#include<stdio.h>
int main(){
char line[50];
int i,j;
printf("Enter a string up to 50 charecters: ");
gets(line);
for(i=0; line[i]!=''; ++i)
{
while (!((line[i]>='a'&&line[i]<='z') || (line[i]>='A'&&line[i]<='Z' || line[i]=='')))
{
for(j=i;line[j]!='';++j)
{
line[j]=line[j+1];
}
line[j]='';
}
}
printf("Output String: ");
puts(line);
return 0;
}
Output
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.