Find Jobs
Hire Freelancers

Functions

$10-15 USD

已完成
已发布超过 21 年前

$10-15 USD

货到付款
This program requires you to write and use some functions, and answer some quiz questions. Part 0 Write a function that prompts the user to enter a line length. If a -99 is entered, then return to the caller the total number of lines printed; otherwise, print an error message if the entered value is less than 0 or greater than 80. If the entered number is between 0 and 80, then prompt the user to enter a character. Print a line using the entered character having a length equal to the entered line length. At most 10 lines can be printed. This value is passed as an argument to the function. Part 1 Write a function that prompts the user to enter two characters. If the user enters a tilde character (~), then return the number of results printed. Otherwise, print a message indicating which character is bigger and which character is smaller. At most 10 results can be printed. This value is passed as an argument to the function. In addition, the sentinel value for this part (i.e. the tilde) is also passed as an argument to the function. Part 2 Write a function that prints the answers to the following questions. There should be only one answer per line. Each answer must be prefixed with the question number followed by a closing (i.e. right) parenthesis. The function returns the number of lines printed. What will the following code snippet print? double d = 10.0; int result = d / 3; cout << result; What will the following code snippet print? int i = 1, j = 2, k = 3; if (i && j == 2 || k) cout << "hello"; else if (!i && !(k == 3)) cout << "Hello"; cout << " world"; What will the following code snippet print? int k=10;k++;++k;k++;if(k<=13)cout<<"yes";else cout <<"no"; How many times will the following loop print the string "foo"? for (int i = 1000; i > 0; i %= 10) cout << "foo" << endl; What value will be assigned to the variable 'i'? int a = 5, b = 10; int i = ((a != b) && (b > 0) && (a <= b)) ? (b * a) : (b - a); Part 3 Prior to ending the program, print the total number of lines printed by all of the functions used in the program. This value does not include heading lines, error messages, and prompts. ## Deliverables 1) Complete and fully-functional working program(s) in executable form as well as complete source code of all work done. 2) Notes All prompts and error messages must be written to the standard error stream. Here are function prototypes you can use. int printQuiz(void); int printLines(int maxLines); int compareChars(int maxResults, char sentinelValue); The body of your main() function may look something like the following. int nLines = 0; // count total number of lines printed int partNbr = 0; // print heading for each Part printed printPartHeading(partNbr++); nLines += printLines(MAX_LINES); printPartHeading(partNbr++); nLines += compareChars(MAX_RESULTS, PART1_SENTINEL_VALUE); printPartHeading(partNbr++); nLines += printQuiz(); printPartHeading(partNbr++); cout << "Total number of lines printed: " << nLines << endl; return EXIT_SUCCESS; // MAX_LINES, MAX_RESULTS, PART1_SENTINEL_VALUE are // programmer defined manifest constants. You do not have to write the function printPartHeading(); however, one extra credit point will be awarded if you do. Output The output of program does not need to include the prompts. The prompts are provided to help give you an idea as to how the program looks from a user's perspective. For documentation purposes, user inputs are enclosed in brackets < > ------ Part 0 ------ Enter a length (-99 to exit this part): <10> Enter a character: <=> ========== Enter a length (-99 to exit this part): <5> Enter a character: <:> ::::: Enter a length (-99 to exit this part): <-1> *** error: -1 is invalid input Enter a length (-99 to exit this part): <-99> ------ Part 1 ------ Enter character number 1 (~ to exit this part): <)> Enter character number 2 (~ to exit this part): <(> ) is greater than ( Enter character number 1 (~ to exit this part): <+> Enter character number 2 (~ to exit this part): <9> 9 is greater than + Enter character number 1 (~ to exit this part): <9> Enter character number 2 (~ to exit this part): <{> { is greater than 9 Enter character number 1 (~ to exit this part): <~> ------ Part 2 ------ 1) 5 2) hello world 3) yes 4) 3 5) 10 ------ Part 3 ------ Total number of lines printed: 10 ## Platform windows xp
项目 ID: 2886972

关于此项目

3提案
远程项目
活跃22 年前

想赚点钱吗?

在Freelancer上竞价的好处

设定您的预算和时间范围
为您的工作获得报酬
简要概述您的提案
免费注册和竞标工作
颁发给:
用户头像
See private message.
$8 USD 在14天之内
4.1 (3条评论)
2.1
2.1
3威客以平均价$9 USD来参与此工作竞价
用户头像
See private message.
$11.05 USD 在14天之内
4.7 (17条评论)
3.0
3.0
用户头像
See private message.
$8.50 USD 在14天之内
0.0 (0条评论)
0.0
0.0

关于客户

FRANCE的国旗
France
5.0
27
会员自10月 13, 2002起

客户认证

谢谢!我们已通过电子邮件向您发送了索取免费积分的链接。
发送电子邮件时出现问题。请再试一次。
已注册用户 发布工作总数
Freelancer ® is a registered Trademark of Freelancer Technology Pty Limited (ACN 142 189 759)
Copyright © 2024 Freelancer Technology Pty Limited (ACN 142 189 759)
加载预览
授予地理位置权限。
您的登录会话已过期而且您已经登出,请再次登录。