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
Draw an ERD that will involve the entity types: Professor, Student, Department and Course. Be sure to add relationship types, key attributes, attributes and multiplicity on the ERD.
Draw an ERD that represents a book in a library system. Be sure to add relationship types, key attributes, attributes and multiplicity on the ERD.
2:21 m Ο 21% AlmaNet WE ARE HIRING Experienced Freshers Salesforce Platform Developer APPLY NOW SEND YOUR CV: Email: hr.almanet@gmail.com Contact: +91 6264643660 Visit: www.almanet.in Locations: India, USA, UK, Vietnam (Remote & Hybrid Options Available)
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