EssayGhost Assignment代写,Essay代写,网课代修,Quiz代考

EssayGhost-Essay代写,作业代写,网课代修代上,cs代写代考

一站式网课代修,论文代写

高质量的Assignment代写、Paper代写、Report代写服务

EG1hao
网课代修代上,cs代写代考
编程案例
您的位置: 主页 > 编程案例 >
C代写/C++代写 CSC B09案例
发布时间:2021-06-29 22:13:43浏览次数:

cs代写价格  cs代考  cs作业代写

Please begin by running “/cmsfaculty/ajr/b09/present”. This records your attendance and is required for you to get the marks for the lab.

Simple first task
Create a “hello, world” program in C (it just outputs “hello, world”) and compile it and make sure it runs properly.
Compile it with “gcc −Wall”. You should always compile with “gcc −Wall”.

Simple second task
Break your “hello, world” program into two .c files. One of them contains the main(), and the other one contains a function which does the actual printing. You would compile with a command like “gcc −Wall main.c hello.c”.
Make sure it compiles with no warnings or error messages, and performs exactly correctly (this is simple enough that you should be able to make it perfect).

Not quite as simple but still pretty simple third task, for submission
Consider a positive integer. If it is even, you divide it by two. If it is odd, you multiply it by three and add one. In either case, you loop around and keep processing until you get down to 1.
As it so happens, it’s an unsolved problem as to whether this algorithm terminates for all positive integers.

Write a program in C which takes a command-line argument which is a positive integer and performs this algorithm, outputting the new number each iteration, until it reaches 1.

Sample outputs: for an argument of 3, it should output 10, 5, 16, 8, 4, 2, 1. (Each number on a separate line, with no punctuation or extraneous whitespace, and your program may or may not print the final “1”.)
For an argument of 27, it produces 111 outputs (check this with “./a.out | wc −l”, although if you don’t print the final “1” the count should be 110).

We haven’t covered what you need to know in C to parse the command-line arguments yet, so please start with /cmsfaculty/ajr/b09/lab/04/starter.c which puts the numeric command-line argument into an int variable named ‘n’, objecting appropriately if the usage is incorrect or the number is not positive.

You can print the value of n with

printf(“%d\n”, n);
Call your file “3n1.c”.

As usual, your file must compile on the UTSC linux machines with “gcc −Wall” with no warning or error messages.

To submit
First of all, you must run “/cmsfaculty/ajr/b09/present”, during the tutorial time, on the console of a tutorial lab workstation.

Then, by noon on Monday February 5, you must submit your C file. Submit with the command

submit -c cscb09w18 -a lab04 3n1.c
You may still change your file and resubmit any time up to the due time, using “−f” as described towards the end of lab one; and you can use “submit −l” as also described in lab one.