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

Program Plan:

  • Include required header files
  • Give the function prototype
  • Define the main function
    • Declare the variable “n”, “val”.
    • Get the number from the user.
    • Call the function “p()”.
    • Check whether “val” equals to “1”.
      • Print the corresponding statement.
    • Otherwise, if the condition fails
      • Print the corresponding statement
  • Definition for the function “p()”
    • 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”.

Blurred answer
Students have asked these similar questions
Write a function prime() that returns 1 if its argument is a prime number and returns 0 otherwise.
The function doit(a,b,c,d) is a function that multiplies the smallest of its integers arguments by 2. If more than one arguments are equal and are the smallest, they are multiplied by 2. For example given a=5,b=3,c=7,d=9, doit (a,b,c,d) changes b to 6. Write the code of the function doit and test it.
Write a function that takes 3 integers (num,den,power) as parameters which represent the rational number num/den and its power and returns the difference of these two fractions. (A/B) to the power of n = A to the power of n/B to the power of n • den can not be zero. • use simplify function.
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