Question 4 Not complete Marked out of 4.00 Flag question Complete the provided program by defining the get_letters() fun

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

Question 4 Not complete Marked out of 4.00 Flag question Complete the provided program by defining the get_letters() fun

Post by answerhappygod »

Question 4 Not Complete Marked Out Of 4 00 Flag Question Complete The Provided Program By Defining The Get Letters Fun 1
Question 4 Not Complete Marked Out Of 4 00 Flag Question Complete The Provided Program By Defining The Get Letters Fun 1 (147.89 KiB) Viewed 12 times
code:
#include <stdio.h>
#include <string.h>
void get_letters(char* letters, int number);
int main(){
char letters[10];
int number;
memset(letters, '\0', 10);
scanf("%d", &number);
get_letters(letters, number);
printf("%s\n", letters);
return 0;
}
//define the get_letters() function
Question 4 Not complete Marked out of 4.00 Flag question Complete the provided program by defining the get_letters() function. From the function declaration, you can see that this function takes 2 parameters: 1. A character pointer letters that will point to the first character in a character array. 2. An integer value number. This integer value indicates how many characters will be read from standard input and stored in the character array pointed to by letters. Use a loop to obtain all of the characters entered through standard input and store them in the character array pointed to by letters. Hint: You will need to handle the new line character that follows every letter entered through standard input. This can easily be done with a small tweak to the format string used with the scanf() function. You can assume that only a single alphabetical letter will be entered each time you read information from standard input and you will never read more than 9 letters in total. Some examples of the program being run are shown below. For example: Input Result 5 abcde a b d e 7 Awesome A W e S O m e
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply