// this is a C programming code please fill out the empty spots from #1 to #24 /*Task 1: Print full name*/ #include #include __1__ scan_name(__2__ size, __3__ name[size]); // function header int main() { int len; bool isDone = false; //default to false since it's not done without running char enter; //this is to avoid the first getChar captures the enter from length //Get name and redo them over and over till the name length is big enough // isDone is our flag to know if we need to run again. // isDone == true means we are done, and vice versa do { printf("\nEnter your full name's length."); printf("Make sure to count spaces and null character:"); scanf("%d%c", &len, &enter); char fullName[len]; isDone = scan_name(len, fullName); }while(!isDone); return 0; } /*Get and print the full name. Return a boolean to check if the length is correct or not. We set the default to be true (assume user counts correctly the size) Similar to task 3, we need to save user input to a variable so we can check. There are 3 things to check: 1. If the inputted char is a new line character. Our string is done. User pressed Enter => done 2. If i is bigger than the last index => user didn't count correctly for size i reaches the last index of the string, and it's not 'Enter', meaning the size is not long enough Set flag to false to run again in main when return Get out of loop 3. None of the above, then it's a normal letter, save inputted char to the string Both case 1 and 2 will get out of loop, and print the name. */ __4__ scan_print_name(__5__ size, __6__ name[size]) { bool isComplete = true; //default flag to true printf("Input your full name: "); for(int i = 0; i <= __7__; i++) { __8__ curChar = __9__(); //call function to get a character if(__10__ == __11__) __12__;//Case 1, get out of loop if(i > size - __13__) //Case2 { printf("Your inputted length is too short.We'll redo this after printing the incomplete name.\n"); isComplete = __14__; //update the flag __15__; //get out of loop and print the name } __16__ = __17__; //case 3 } //this is outside of loop // which means that we need to add the null char // to the last index of the string __18__[size - __19__] = __20__; //print back printf("Your full name: __21__\n", __22__); //return flag __23__ __24__;
// this is a C programming code please fill out the empty spots from #1 to #24 /*Task 1: Print full name*/ #include #include __1__ scan_name(__2__ size, __3__ name[size]); // function header int main() { int len; bool isDone = false; //default to false since it's not done without running char enter; //this is to avoid the first getChar captures the enter from length //Get name and redo them over and over till the name length is big enough // isDone is our flag to know if we need to run again. // isDone == true means we are done, and vice versa do { printf("\nEnter your full name's length."); printf("Make sure to count spaces and null character:"); scanf("%d%c", &len, &enter); char fullName[len]; isDone = scan_name(len, fullName); }while(!isDone); return 0; } /*Get and print the full name. Return a boolean to check if the length is correct or not. We set the default to be true (assume user counts correctly the size) Similar to task 3, we need to save user input to a variable so we can check. There are 3 things to check: 1. If the inputted char is a new line character. Our string is done. User pressed Enter => done 2. If i is bigger than the last index => user didn't count correctly for size i reaches the last index of the string, and it's not 'Enter', meaning the size is not long enough Set flag to false to run again in main when return Get out of loop 3. None of the above, then it's a normal letter, save inputted char to the string Both case 1 and 2 will get out of loop, and print the name. */ __4__ scan_print_name(__5__ size, __6__ name[size]) { bool isComplete = true; //default flag to true printf("Input your full name: "); for(int i = 0; i <= __7__; i++) { __8__ curChar = __9__(); //call function to get a character if(__10__ == __11__) __12__;//Case 1, get out of loop if(i > size - __13__) //Case2 { printf("Your inputted length is too short.We'll redo this after printing the incomplete name.\n"); isComplete = __14__; //update the flag __15__; //get out of loop and print the name } __16__ = __17__; //case 3 } //this is outside of loop // which means that we need to add the null char // to the last index of the string __18__[size - __19__] = __20__; //print back printf("Your full name: __21__\n", __22__); //return flag __23__ __24__;
Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
Related questions
Question
// this is a C programming code please fill out the empty spots from #1 to #24 /*Task 1: Print full name*/ #include<stdio.h> #include<stdbool.h> __1__ scan_name(__2__ size, __3__ name[size]); // function header int main() { int len; bool isDone = false; //default to false since it's not done without running char enter; //this is to avoid the first getChar captures the enter from length //Get name and redo them over and over till the name length is big enough // isDone is our flag to know if we need to run again. // isDone == true means we are done, and vice versa do { printf("\nEnter your full name's length."); printf("Make sure to count spaces and null character:"); scanf("%d%c", &len, &enter); char fullName[len]; isDone = scan_name(len, fullName); }while(!isDone); return 0; } /*Get and print the full name. Return a boolean to check if the length is correct or not. We set the default to be true (assume user counts correctly the size) Similar to task 3, we need to save user input to a variable so we can check. There are 3 things to check: 1. If the inputted char is a new line character. Our string is done. User pressed Enter => done 2. If i is bigger than the last index => user didn't count correctly for size i reaches the last index of the string, and it's not 'Enter', meaning the size is not long enough Set flag to false to run again in main when return Get out of loop 3. None of the above, then it's a normal letter, save inputted char to the string Both case 1 and 2 will get out of loop, and print the name. */ __4__ scan_print_name(__5__ size, __6__ name[size]) { bool isComplete = true; //default flag to true printf("Input your full name: "); for(int i = 0; i <= __7__; i++) { __8__ curChar = __9__(); //call function to get a character if(__10__ == __11__) __12__;//Case 1, get out of loop if(i > size - __13__) //Case2 { printf("Your inputted length is too short.We'll redo this after printing the incomplete name.\n"); isComplete = __14__; //update the flag __15__; //get out of loop and print the name } __16__ = __17__; //case 3 } //this is outside of loop // which means that we need to add the null char // to the last index of the string __18__[size - __19__] = __20__; //print back printf("Your full name: __21__\n", __22__); //return flag __23__ __24__;
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 3 steps
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY