Questions by bjenkins - Page 8
This is a program written in C. Please don't have a complicated code. It should be simple and straight forward with comments to understand. Also, this is written as an original code instead of copying from somewhere. Thank you in advance. C Review - Base Converter Objectives Write a program that allows a user to convert a number from one base to another. Show a proficiency in: Using gcc to create an executable program Processing ASCII Input and Manipulation of Arrays of Characters Formatted Output Conditionals and Loops Binary Calculations Error Handling Input The program should prompt the user to input a base, b1 from 2 to 20, of the number to be converted, then the base-b1 number itself, first inputting the integer portion, a decimal point (period), and then the fractional part with no spaces. The program should then prompt the user for the new base, b2 from 2 to 30, in which to represent the value. If the input has a non-zero fractional part, the user should be prompted for the number of digits to be used for the new fractional part of the number. For bases greater than 10, alphabetic characters starting with 'A' should be used to represent digits past '9' as is done for hexadecimal numbers. Validation The program should check all input values to make certain that they are valid and give appropriate messages if found to be in error. Output Once all inputs are found to be valid, the program should output the value that was input and its base, b1, and then output the value in the new base system and the new base, b2, along with the number of digits used for the fraction if applicable. For example, FEED.BEEF base 16 equals 1111111011101101.1011111 base 2 to seven decimal places. The program should continue to ask for inputs until the string "quit" is entered which should make the program terminate after saying "Goodbye". Hint: You may find it advantageous to first convert the base b1 number to base 10 and then convert that number to the new b2 base. Use the following line to compile your program: gcc -Wall -g p1.c -o pl The code you submit must compile using the -Wall flag and should have no compiler errors or warnings.
Once upon a time, a mother duckling sat on her eggs with great impatience. How long would it be before they hatched? Finally, one summer day, the mother duckling watched as the eggs cracked, and her cute, yellow ducklings waddled into the world. She was filled with joy until she noticed that one egg, which was larger than all of the others, remained. After many hours, the egg cracked. A large, gray duckling emerged. The mother duck was horrified at the duckling's appearance. The mother duck's only comfort was that the ugly duckling could swim and dive under the water.As the ugly duckling grew, many animals in the pond criticized him. His feathers were too dark, his neck was too long, and his body was too big. His fellow ducklings refused to recognize that underneath the feathers, the ugly duckling was kind, good, and gentle. The ugly duckling shed many tears because none of the other animals would play with him.Read this excerpt from the fairy tale The Princess and the Pea.One evening, there was a terrible storm. The wind howled, thunder shook the stone walls, and lightning filled the dark night sky. Through the pelting of the rain, there came a knock at the door. When the king opened the door, he saw a bedraggled girl, soaked to the skin and covered in mud. He ushered her into the castle so that she could warm herself by the fire."Why is a young servant girl like you wandering about on such a ferocious night?" queried the king.The disheveled maiden looked at the king in disbelief. "I am a princess, come to see the prince," she explained, all the while shivering.The king summoned his wife, the queen, for advice. The queen looked at the hideous creature in disbelief, thinking that no princess would ever allow herself to be found in such a state.How do the authors illustrate the theme that people should not be judged based on their appearances? Both authors show that the main characters are not afraid of getting wet and dirty in order to live active lives. Both authors show the main characters being labeled in a negative manner based on their appearances. Both authors showed the main characters exercising patience with other people. Both authors showed the main characters wanting to make friends with others.