
Write a printf or scanf statement for each of the following:
- Print unsigned integer 40000 left justified in a 15-digit field with 8 digits.
- Read a hexadecimal value into variable hex.
- Print 200 with and without a sign.
- Print 100 in hexadecimal form preceded by 0x.
- Read characters into array s until the letter p is encountered.
- Print 1.234 in a 9-digit field with preceding zeros.
- Read a time of the form hh:mm:ss, storing the parts of the time in the integer variables hour, minute and second. Skip the colons (:) in the input stream. Use the assignment suppression character.
- Read a string of the form “characters” from the standard input. Store the string in character array s. Eliminate the quotation marks from the input stream.
- Read a time of the form hh:mm:ss, storing the parts of the time in the integer variables hour, minute and second. Skip the colons (:) in the input stream. Do not use the assignment suppression character.
a.

To write a printf or scanf statement for given condition.
Explanation of Solution
Given information:
Print unsigned integer 40000 left justified in a 15-digit field with 8 digits.
Explanation:
Following is the print statement to print an unsigned integer 40000 left justified in a 15-digit field with 8 digits:
printf ( “%-15.8u”,40000 ) ;
The printf displays the given number as 8 digits with left justification in a l5 digit field.
- -15 placed to the immediate right of % sign, is used to left justify the number and occupy 15 spaces.
- Digit 8 after the decimal point places zeros to the left of the number to make it an 8-digit number.
- Conversion specifier u is used to print unsigned numbers.
b.

To write a printf or scanf statement for given condition.
Explanation of Solution
Given information:
Read a hexadecimal value into variable hex.
Explanation:
Following is the scanf statement to read a hexadecimal value into hex variable:
scanf ( “%x”, hex ) ;
The scanf statement inputs a hexadecimal number in the variable named hex using conversion specifier %x.
c.

To write a printf or scanf statement for given condition.
Explanation of Solution
Given information:
Print 200 with and without a sign.
Explanation:
Following is the printf statement to print 200 with and without a sign:
printf ( “%+d\n %d\n”, 200, 200 ) ;
The printf statement prints the value 200, with and without a plus sign. If we place a + sign immediate to the right of %sign, then, a positive value is printed with a plus sign and a negative value is printed with a minus sign.
d.

To write a printf or scanf statement for given condition.
Explanation of Solution
Given information:
Print 100 in hexadecimal form preceded by 0x.
Explanation:
Following is the printf statement to print 100 in hexadecimal form preceded by 0x:
printf ( “%#x\n”, 100 ) ;
The printf statement is used to print 100 preceded by Ox. This is accomplished by using a # flag placed immediate to the right of % sign in the field.
e.

To write a printf or scanf statement for given condition.
Explanation of Solution
Given information:
Read characters into arrays s until the letter p is encountered.
Explanation:
Following is the scanf statement to read characters into arrays s until the letter p is encountered:
scanf ( “%[^p]”, s ) ;
The scanf statement is used to read the string until the letter p appears. This is achieved by inverted scan set, that is, by placing a Caret (^) before the character.
f.

To write a printf or scanf statement for given condition.
Explanation of Solution
Given information:
Print 1.234 in a 9-digit field with preceding zeros.
Explanation:
Following is the printf statement to print 1.234 in a 9-digit field with preceding zeros:
printf ( “%09.3f\n”, 1.234 ) ;
The printf statement prints the given floating-point number in the field of 9 digits and preceded by zeros. Thus achieved by placing 09 immediate to the right of % sign.
Digit 3 after the decimal point is used to provide precision up to 3 values.
g.

To write a printf or scanf statement for the given condition.
Explanation of Solution
Given information:
Write time of the hh: mm: ss type, storing the timepieces in the hour, minute and second integer variables. Skip the colons (:) through the input tube. Use the character assignment Suppression.
Explanation:
Following is the scanf statement to read the time in form hh:mm:ss -:
scanf ( “%d*c%d*c%d”, &hour, &minute, &second ) ;
The scanf statement is used to input the time in the form hh:mm:ss. The colons (:) are eliminated using the suppression character (*) in the field.
h.

To write a printf or scanf statement for given condition.
Explanation of Solution
Given information:
Read a string from the standard input of the "characters" type. Place the string in character array s. Eliminate quotation marks from the input stream.
Explanation:
Following is the scanf statement to read a string of characters and store in array s -:
scanf ( “\”%[^\“]”, s ) ;
The scanf statement is used to input a string by the in quotation marks in a character array, s, and eliminate those quotation marks.
This is achieved by using an inverted scan set where a caret (^) before the \” sign is placed.
i.

To write a printf or scanf statement for given condition.
Explanation of Solution
Given information:
Read a time of type hh: mm: ss, storing time pieces in the hour, minute and second integer variables. Skip the input stream colons (:). Do not use the character Assignment Suppression.
Explanation:
Following is the scanf statement to read the time in form hh:mm:ss and skip the colons without using assignment suppression character -:
scanf ( “%d:%d:%d: ”, &hour, &minute, &second ) ;
The scanf statement is used to input the time in the form hh:mm:ss. The colons (:) are eliminated by placing colons (:) in the scanf statement as shown, if we do not have to put suppression character.
Want to see more full solutions like this?
Chapter 9 Solutions
C How To Program Plus Mylab Programming With Pearson Etext -- Access Card Package (8th Edition)
Additional Engineering Textbook Solutions
Web Development and Design Foundations with HTML5 (8th Edition)
SURVEY OF OPERATING SYSTEMS
Introduction To Programming Using Visual Basic (11th Edition)
Starting Out With Visual Basic (8th Edition)
Computer Science: An Overview (13th Edition) (What's New in Computer Science)
Starting Out with Java: From Control Structures through Data Structures (4th Edition) (What's New in Computer Science)
- A business case scenario and asked to formulate an appropriate software design solution. Theyshould complete the case and upload the solution. will be required to read the case,identify and document the key issues, problems, and opportunities presented, and then design,and develop an appropriate integrated design solution to the problem. mustdemonstrate good spreadsheet, database, analytical, and word-processing skills whendeveloping solutions. Additionally, must be creative and demonstrate synthesising andapplying Database Management and Data Analytics Principles learned in the course. They willalso need to research some aspects of the assessment. CASE BACKGROUNDMGMT SS STATS, an umbrella body that facilitates and serves various Social SecurityOrganizations/Departments within the Caribbean territories, stoodpoised to meet the needs of its stakeholders by launching an onlinedatabase at www.SSDCI.gov. The database will provide membersand the public access to the complete set of…arrow_forwardUsing MATLAB symbolic toolbox, given these 3 equations, how would you solve for mu = function(theta), making sure that there are no mu's on the right hand side, making sure theta-dot-dot, theta-dot-squared- and N aren't in the final answer either.arrow_forwardAfter playing our giving implementation, your task is to implement Dinning Philosophers with semaphore in C, by including and Your implementation will require creating five philosophers, each identified by a number 0.4. Each philosopher will run as a separate thread. Create threads using Pthreads as discussed in the Lecture slides on Chapter 4 and Practice Lab on Threads. Your solution needs to accomplish the following: Implement in C (15 points) 1. dp1.c - You are to provide your solution to this assignment as a single C program named 'dp1.c using semaphore. Explain in you code (as comments) that the dead lock will happen or not. If there is a possible deadlock, you can simply solve the deadlock by pick the fork in order like the first solution in our slides. Solve Deadlock by Footman (15 points) 1. Here is a new solution to overcome the deadlock. The Dining Philosophers decide to hire a footman whose task to allow only four philosophers to sit on the table. When entering and…arrow_forward
- 8.4 Self-Bias Configuration 20. Determine Zi. Zo. and A,, for the network of Fig. 8.73 if gf, = 3000 μS and gos = 50 μs. 21. Determine Z, Zo, and A, for the network of Fig. 8.73 if the 20-uF capacitor is removed and the parameters of the network are the same as in Problem 20. Compare results with those of Problem 20. +12 V 3.3 ΚΩ HE C₂ Vo Z Zo C₁ 10 ΜΩ Z₁ 1.1 ΚΩ Cs 20 µF FIG. 8.73 Problems 20, 21, 22, and 59.arrow_forward21. Determine Zi, Zo, and A, for the network of Fig. 8.73 if the 20-μF capacitor is removed and the parameters of the network are the same as in Problem 20. Compare results with those of Problem 20. +12 V 3.3 ΚΩ +6 C₂ C₁ Z₁ 10 ΜΩ 1.1 ΚΩ Cs 20 μF FIG. 8.73 Zoarrow_forwardNinth Edition Determine Zi, Zo and Av 20 V Zi + 1 ΜΩ 2 ΚΩ HH Z IDSS= 6MA Vp=-6V Yos = 40μS 20 and 47arrow_forward
- What is the worst case time complexity of the following algorithm for i = 1 to x do for j = 2^((i-1)x) to 2^(in) do print(i,j)arrow_forwardProve for each pair of expression f(n) and g(n) whether f(n) is big O, little o Ω,ω or Θ of g(n). For each case it is possible that more than one of these conditions is satisfied:1. f(n) =log(n2^n), g(n) = log(sqrt(n)2^(n^2))2. f(n) =nsqrt(n) +log(n^n), g(n) =n + sqrt(n)lognarrow_forwardI need to make a parallel version of this sequential codearrow_forward
- I need to make a parallel version of this sequential code.arrow_forwardBenefits of using arrays as instance variables: What are the advantages of incorporating arrays as instance variables within a class? Initializing and managing arrays: How do you initialize and manage arrays within class constructors and mutators (setters)? Example of using arrays as instance variables: Share an example where you have used arrays as instance variables and discuss its application in a real-world scenario. Common mistakes with arrays as instance variables: What are some common mistakes to avoid when working with arrays as instance variables? Information hiding violations: What is the potential violation of information hiding when using arrays as instance variables? How can this be resolved?arrow_forwardDo you think that computers should replace teachers? Give three references with your answer.arrow_forward
- C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology PtrC++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage LearningProgramming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:Cengage
- Microsoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTProgramming with Microsoft Visual Basic 2017Computer ScienceISBN:9781337102124Author:Diane ZakPublisher:Cengage Learning




