Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Please do 3-6 C language please. I put photos of section 7.1 for one of the questions 6 it'll help if 3. Rewrite the program
Please do 3-6 C language please. I put photos of section 7.1 for one of the questions 6 it'll help if
3. Rewrite the program in Programming Project 2 so that it prints the reversal of a three-digit number without using arithmetic to split the number into diits. Hint: See the upe.c pro- gram of Scction 4.1 4. Write a program that reads an integer entered by the user and displays it in octal (base 8): Enter a number between 0 and 32767: 1953 In octal, your number is: 03641 The output should be displayed using five digits, even if fewer digits are sufficient. Hint: To convert the number to octal, first divide it by 8; the remainder is the last digit of the octal number (1. in this case). Then divide the original number by 8 and repeat the process to arrive at the next-to-last digit. (printf is capable of displaying numbers in base 8, as we'll sce in Chapter 7, so there's actually an easier way to write this program.) 1 5. Rewrite the upc.c program of Section 4.1 so that the user enters 11 digits at one time instead of entering one digit, then five digits, and then another five digits. Enter the first 11 digits of a UPC: 01380015173 Check digit: 5 2 5 2 6. European countries use a 13-digit code, known as a European Article Number (EAN) instead of the 12-digit Universal Product Code (UPC) found in North America. Each EAN ends with a check digit, just as a UPC does. The technique for calculating the check digit is 2 also similar Add the second. fourth, sixth, cighth, tenth. and twelfth digits. Add the first, third. fifth. seventh. ninth. and eleventh digits. Multiply the first sum by 3 and add it to the second sum which has the value 32,767 (215-1). The largest 32-bit integer is which has the value 2,147,483,647 (231 1). An integer with no sign bit (the left- most bit is considered part of the number's magnitude) is said to be unsigned. The largest 16-bit unsigned integer is 65,535 (216-1), and the largest 32-bit unsigned integer is 4,294,967.295 (232 - 1). By default, integer variables are signed in C-the leftmost bit is reserved for the sign. To tell the compiler that a variable has no sign bit, we declare it to be unsigned. Unsigned numbers are primarily useful for systems programming and low-level, machine-dependent applications. We'll discuss typical applications for unsigned numbers in Chapter 20; until then, we'll generally avoid them. C's integer types come in different sizes. The int lype is usually 32 bits, but may be 16 bits on older CPUs. Since some programs require numbers that are too large to store in int form, C also provides long integers. At times, we may need to conserve memory by instructing the compiler to store a number in less space than normal; such a number is called a short integer To construct an integer type that exactly meets our needs, we can specify that a variable is long or short, signed or unsigned. We can even combine specifiers (e.g., long unsigned int). However, only the following six combi- nations actually produce different types: short int unsigned short int int unsigned int conserve memory by instructing the compiler to store a number in less space than normal; such a number is called a short integer. To construct an integer type that exactly meets our needs, we can specify that a variable is long or short, signed or unsigned. We can even combine specifiers (e.g., long unsign'ed int). However, only the following six combi- nations actually produce different types: short int unsigned short int int unsigned int long int unsigned long int OSL Other combinations are synonyms for one of these six types. (For example. Iong signed int is the same as long int, since integers arc always signed unless r produc Hous otherwise specified.) Incidentally, the order of the specifiers doesn't matter;2019 unsigned short int is the same as short unsigned int. C allows us to abbreviate the names of integer types by dropping the word int. For example, unsigned short int may be abbreviated to unsigned short, and long int may be abbreviated to just long. Omitting int is a widespread practice among C programmers, and kome newer C-based languages (including Java) actually require the programmer to write short or long rather than short int or long int. For these reasons, I'll often omit the word int when it's not strictly necessaryStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started