Posted: December 15th, 2023
Way back in homework P01, you wrote the classic “Hello, World!” program in Java. Now that we’re learning a
bit about C , let’s retread that hallowed ground!Full CreditFor this full credit assignment, we will repeat both the P01 full credit and bonus assignments – in C !If you haven’t already, set up your C development environment using guidance from Lecture 00 (slides14-15). Then in cse1325/P08/full_credit, create and run the C “Hello, World!” program in file hello.cppusing std::cout, replacing “World” with your name. Take a screenshot of your program running, and nameit hello_me.png.Then create and run a C program from file hello_all.cpp that asks the user for their name, then prints “Hello,[name]”, where [name] is the name they enter. Test this at least 3 times – with a single-word name, with amult-word name separated by spaces, and by a name with different (potentially weird) characters. Take ascreenshot of your program running all of these tests, and name it hello_all.png. As long as your programprints something after “Hello, “, you get full credit regardless of the outcome of these 3 or more tests.Add hello_me.cpp, hello_me.png, hello_all.cpp, and hello_all.png to git, commit, and push to GitHub. Bonus
write a C program in file reverse.cpp that prints each of its parameters with thecharacters reversed. That is, ./a.out hello world would print olleh dlrow (on one line or separatelines, your choice).No screenshots are required.Hint: std::string has a constructor that will accept a char*.Hint: std::string is a collection of chars.Hint: The std::reverse function (from ) will reverse a collection in place. To reverse any collectionfoo, write std::reverse(foo.begin(), foo.end()); (this rather odd syntax was chosen so that asubset of a collection could be easily reversed).Add, commit, and push all files.
Extreme Bonus write a program in file sorted.cpp that reads all newline-terminated lines oftext from the console until end of file. Then, print all of the lines of text back out sorted in alphabetic order.No screenshots are required.Hint: The equivalent of Java’s ArrayList would be the std::vector (from). Rather than add, use the push_back method, e.g.,std::vector v; v.push_back(“Hi!”);Hint: std::vector is a collection of objects of the type specified in the angle brackets .Hint: The std::sort function (from ) will sort a collection in place. To sort any collection foo, writestd::sort(foo.begin(), foo.end()); (this rather odd syntax was chosen so that a subset of acollection could be easily sorted).Hint: You can redirect a text file foo.txt into your program with bash’s < operator, e.g., ./a.out < foo.txt Ifyou prefer to type the lines of text yourself, you can type an end of file signal using Control-d (for Linux or Mac)or Control-z (for Windows).Add, commit, and push all files.
Place an order in 3 easy steps. Takes less than 5 mins.