Can someone write a basic program in C using the following instructions: (1) Pro
ID: 3594318 • Letter: C
Question
Can someone write a basic program in C using the following instructions:
(1) Prompt the user to enter a string of their choosing. Output the string (2) Complete the GetNumOfCharacters) function, which returns the number of characters in the user's string. We encourage you to use a for loop in this function. 3. In main0, call the GetNumOfCharacters) function and then output the returned result. 4.) Implement the OutputWithoutWhitespace0 function. OutputWithoutWhitespace0 outputs the strings characters except for whitespace (spaces, tabs). Note: A tab is t. Call the OutputWithoutWhitespace0) function in main). (1) Prompt the user to enter a string of their choosing. Output the sting. (1 pt) Ex Enter a sentence or phrase: The only thing we have to fear is fear itself You entered: The only thing we have to fear is fear itself. (2) Complete the GetNumorcharacters function, which retums the number of characters in the users sting. we encourage you to use a for loop in this function (2 pts) (3) In main), call the GetNumotCharacterso function and then output the retumed result. (1 pt) (4) Implement the OutputWithoutWhitespace) function. OutputWithoutWhitespace) outputs the string's characters except for whitespace (spaces, tabs). Note: A tab is·w. Call the OutputWithoutWhitespaceO function in main(). (2 pts) Ex Enter a sentence or phrase: The only thing we have to fear is fear itself You entered: The only thing we have to fear is fear itself Number of characters: 46 String with no whitespace: Theonlythingwehavetofearisfearitself Lab Subsion 5.19. 1: Warm up: Text analyzer & modifier (C++) Load defaut template lemsnpp 1 4include ciostream> 2 include 3 using nanespace std; 5 //Returns the nunber of characters in usrStr 6 int Getivnofcharactersconst string usrstr) { ,. Type your code here. 1e 1 int main) 13 14 Type your code here 15 16 return e;Explanation / Answer
//This question is repeated and i'm trying to answer it again.
#include <string.h>
#include <stdio.h>
//Declaration
void Get_NumOf_Characters(char *Source_str);
void Output_Without_Whitespace(char *Sourec_str);
//Main starts
int main()
{
char mainString[100];
printf("Please Enter the string ");
gets(mainString);
printf("Thank you : The entered String is ");
puts(mainString);
Get_NumOf_Characters(mainString);
Output_Without_Whitespace(mainString);
return 0;
}
//Function definition to calculate the number of chacters
void Get_NumOf_Characters(char *Source_str){
int length=0;
for (length=0;(*Source_str!='');length++){ //Keep on calculating till gets null at the end
Source_str++;
}
printf("The number of characters::::: %d ",length);
}
//Function definition to remove the white space
void Output_Without_Whitespace(char *Sourec_str){
int countVal = 0;
for (int i = 0; Sourec_str[i]; i++)
if (Sourec_str[i] != ' ')
Sourec_str[countVal++] = Sourec_str[i]; /*It just tries to copy the chacter to the same string except null chacter*/
Sourec_str[countVal] = ''; /*When all the chacter are copied then it puts null at the end*/
printf("Thank you :The resulting String without the white space::::: ");
puts(Sourec_str);
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.