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
reminder it an exercice not a grading work             GETTING STARTED Open the file SC_EX19_EOM2-1_FirstLastNamexlsx, available for download from the SAM website. Save the file as SC_EX19_EOM2-1_FirstLastNamexlsx by changing the “1” to a “2”. If you do not see the .xlsx file extension in the Save As dialog box, do not type it. The program will add the file extension for you automatically. With the file SC_EX19_EOM2-1_FirstLastNamexlsx still open, ensure that your first and last name is displayed in cell B6 of the Documentation sheet. If cell B6 does not display your name, delete the file and download a new copy from the SAM website. Brad Kauffman is the senior director of projects for Rivera Engineering in Miami, Florida. The company performs engineering projects for public utilities and energy companies. Brad has started to create an Excel workbook to track estimated and actual hours and billing amounts for each project. He asks you to format the workbook to make the…
Need help completing this algorithm here in coding! 2
Whats wrong the pseudocode here??
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