Programming in C
Programming in C
4th Edition
ISBN: 9780321776419
Author: Stephen G. Kochan
Publisher: Addison-Wesley
Question
Book Icon
Chapter 7, Problem 14E

7.10

Program Plan Intro

Modified version of the exercise 7.10 with the global variables:

Program Plan:

  • Include required header files.
  • Give the function prototype.
  • Declare the variable “n” and “val” as global variable
  • Define the main function,
    • Get the number from the user.
    • Call the function “prime()”.
    • Check whether “val” equals to “1”.
      • Print the corresponding statement.
    • Otherwise, if the condition fails,
      • Print the corresponding statement.
  • Definition for the function “prime()”,
    • Declare the variable “i”.
      • Use for loop to check the condition.
        • Check whether the remainder equals to 0.
          • Return the value “0”.
        • Return the value “1”.

a)

Program Plan Intro

Modified version of the exercise 7.12(a) with the global variables:

Program Plan:

  • Include required header files
  • Declare and initialize the array values globally
  • Declare the array “Arr_2” globally.
  • Definition for the function “isTrans(int A[4][5], int B[5][4])”
    • Declare the variable “k” and “l”.
    • For loop to check whether “k” is less than “4”
    • For loop to check whether “j” is less than “5”
      • Condition to check if both the elements in the array are not equal.
        • Return the value “0”.
      • Return the value “1”.
  • Definition for the function “transposeMatrix(int A[4][5], int B[5][4])”
    • Declare the variable “k” and “l”.
    • For loop to check whether “k” is less than “4”
    • For loop to check whether “j” is less than “5”
      • Condition to check if both the elements in the array are equal.
        • Return the value “0”.
    • Check whether “isTrans(A,B)” equals to 1.
      • For loop to check whether “k” is less than “5”
        • For loop to check whether “l” is less than “4”
          • Print the element.
        • Print new line.
      • Otherwise, print the corresponding statement inside “else” clause.
  • Define the main function
    • Call the function “transpose()” by passing the array.
    • Return the value “0”.

b)

Program Plan Intro

Modified version of the exercise 7.12(b) with the global variables:

Program Plan:

  • Include required header files
  • Definition for the function “isTrans(int A[row][col], int B[row][col])”
    • Declare the variable “k” and “l”.
    • For loop to check whether “k” is less than “row”
    • For loop to check whether “j” is less than “col”
      • Condition to check if both the elements in the array are not equal.
        • Return the value “0”.
      • Return the value “1”.
  • Definition for the function “t(int A[row][col], int B[row][col])”
    • Declare the variable “k” and “l”.
    • For loop to check whether “k” is less than “row”
    • For loop to check whether “j” is less than “col”
      • Condition to check if both the elements in the array are equal.
        • Return the value “0”.
    • Check whether “isTrans(A,B)” equals to 1.
      • For loop to check whether “k” is less than “col”
        • For loop to check whether “l” is less than “row”
          • Print the element.
        • Print new line.
      • Otherwise, print the corresponding statement inside “else” clause.
  • Define the main function
    • Declare and initialize the array values.
    • Declare the array “Arr_2”.
    • Call the function “transpose()” by passing the array.
    • Return the value “0”.

7.13

Program Plan Intro

Modified version of the exercise 7.13 with the global variables:

Program Plan:

  • Include required header files.
  • Declare and initialize the array as global.
  • Declare the variable “n” as global variable.
  • Definition for the function “sort()”.
    • Declare the variables.
    • Condition to check the “i<n-1”.
      • Condition to check the “j<n”.
        • Check whether to sort in increasing order.
          • Assign “a[i] ” to “temp”.
          • Assign “a[j] ” to “a[i]”.
          • Assign “a[j]” to “temp”.
        • Check whether to sort in decreasing order.
          • Assign “a[i]” to “temp”.
          • Assign “a[j] ” to “a[i]”.
          • Assign “a[j]” to “temp”
  • Define the main function
    • Print the statement.
    • Loop to traverse the array.
      • Print the element.
    • Call the function “sort()”.
    • Loop to traverse the array.
      • Print the element.
      • Print new line
      • Return the value “0”.

Blurred answer
Students have asked these similar questions
Lab 07: Java Graphics (Bonus lab) In this lab, we'll be practicing what we learned about GUIs, and Mouse events. You will need to implement the following: ➤ A GUI with a drawing panel. We can click in this panel, and you will capture those clicks as a Point (see java.awt.Point) in a PointCollection class (you need to build this). о The points need to be represented by circles. Below the drawing panel, you will need 5 buttons: о An input button to register your mouse to the drawing panel. ○ о о A show button to paint the points in your collection on the drawing panel. A button to shift all the points to the left by 50 pixels. The x position of the points is not allowed to go below zero. Another button to shift all the points to the right 50 pixels. The x position of the points cannot go further than the You can implement this GUI in any way you choose. I suggest using the BorderLayout for a panel containing the buttons, and a GridLayout to hold the drawing panel and button panels.…
If a UDP datagram is sent from host A, port P to host B, port Q, but at host B there is no process listening to port Q, then B is to send back an ICMP Port Unreachable message to A. Like all ICMP messages, this is addressed to A as a whole, not to port P on A. (a)  Give an example of when an application might want to receive such ICMP messages. (b)  Find out what an application has to do, on the operating system of your choice, to receive such messages. (c)  Why might it not be a good idea to send such messages directly back to the originating port P on A?
Discuss how business intelligence and data visualization work together to help decision-makers and data users. Provide 2 specific use cases.
Knowledge Booster
Background pattern image
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Text book image
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
Text book image
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:9781337102124
Author:Diane Zak
Publisher:Cengage Learning
Text book image
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Text book image
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage