Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Could someone walk me though how to string in c? #include <stdio.h> #include <st

ID: 674209 • Letter: C

Question

Could someone walk me though how to string in c?

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(){
char fname[20];
printf("Enter your first name: ");
scanf("%s", &fname);
  
// strlen() function used to calculate the length of the string
int len = strlen(fname);
printf("There are %d letters in your first name ", len);

// TODO: print each letter in a separate line

//TODO: print all letters in a single line but put a space between each letters
printWithSpaces(fname);
return 0;
}

/* Complete the following function */
/* Use proper return type and arguments */
printWithSpaces(){


}

Explanation / Answer

#include <stdio.h>

#include <stdlib.h>

#include <string.h>

void printWithSpaces(char *);

int main(){

char fname[20];

printf("Enter your first name: ");

scanf("%s", &fname);

  

// strlen() function used to calculate the length of the string

int len = strlen(fname);

printf("There are %d letters in your first name ", len);

// TODO: print each letter in a separate line

  

//TODO: print all letters in a single line but put a space between each letters

printWithSpaces(fname);

return 0;

}

/* Complete the following function */

/* Use proper return type and arguments */

void printWithSpaces(char *fname){

int index=0;

while(fname[index] != '') {

printf("%c ", fname[index++]);

}

printf(" ");

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote