Programming in C
4th Edition
ISBN: 9780321776419
Author: Stephen G. Kochan
Publisher: Addison-Wesley
expand_more
expand_more
format_list_bulleted
Question
Chapter 7, Problem 2E
Program Plan Intro
Program Plan:
- Include required header files
- Give the function prototype
- Define the main function
- Declare the variable “number” and “counter” as “int”.
- For loop to increment the value of counter.
- Get the number from the user.
- Call the function “calculateTriangularNumber ()”.
- Return the value “0”.
- Definition for the function “calculateTriangularNumber()”
- Declare the variable “i” , “t” as “int”.
- For loop to check the condition.
- Add the value of “i” and store it in the variable “t”.
- Return the value of “t”.
- For loop to check the condition.
- Declare the variable “i” , “t” as “int”.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Modify Program 7.4 so the value of
triangularNumber
is returned by the
calculateTriangularNumber() function to the main() function. Then modify the main()
function so that it calls the new version of the calculateTriangularNumber() function
accordingly to display the results.
(Note: Modify the program 7.4 in the similar way that program 7.5 is revised to program
7.6. All the codes are included in the lecture notes.
What is wrong in the following function?
Write a program with two functions and a main(), each having at least two parameters. The functions need to at least be able to pass information between each other. Each function must return values as well. Write your code, test your code, and draw illustrations to show how information passes between the functions.
Chapter 7 Solutions
Programming in C
Ch. 7 - Type in and run the 17 programs presented in this...Ch. 7 - Prob. 2ECh. 7 - Modify Program 7.8 so that the value of e is...Ch. 7 - Modify Program 7.8 so that the value of g is...Ch. 7 - Prob. 6ECh. 7 - Write a function that raises an integer to a...Ch. 7 - Prob. 8ECh. 7 - The least common multiple (1cm) of two positive...Ch. 7 - Prob. 10ECh. 7 - Write a function called a that takes two...
Knowledge Booster
Similar questions
- I need help implement this function.arrow_forwardChange this question to work using a function. decide what the name of the function of each should be, how many parameters are required and what value needs to be returned. You're no longer required to solve the problem - try to re-manage your code to be a function. Write a program that uses input to prompt a user for their name and then welcomes them. Enter your name: Chuck Hello Chuckarrow_forwardChange this question to work using a function. decide what the name of the function of each should be, how many parameters are required and what value needs to be returned. You're no longer required to solve the problem - try to re-manage your code to be a function. In many jurisdictions a small deposit is added to drink containers to encourage people to recycle them. In one particular jurisdiction, drink containers holding one liter or less have a $0.10 deposit, and drink containers holding more than one liter have a $0.25 deposit.arrow_forward
- iii. Add a function named lowercase() to this program that takes a list of uppercase letters as a parameter (e.g., x). This function must convert each uppercase letter in x to lowercase and return the list. Your function must use the ord() and chr() functions to solve this problem. You must NOT use the built-in lower() method. Hint: for any letter, the difference between its lowercase and uppercase ASCII values is 32. For example, ASCII values of 'a' and 'A' are 97 and 65, respectively; ASCII values of 'z' and 'Z' are 122 and 90, respectively.arrow_forwardThe purpose of this exercise is to take code from a previous exercise and encapsulate it in a function that takes parameters. You should start with a working solution to exercise a. Write a function called PrintDate American () that takes the day, month and year as parameters and that prints them in American format. b. Test your function by invoking it from main() and passing appropriate argu- ments. The output should look something like this (except that the date might be different): 3/29/2009 c. Once you have debugged Print Date American (), write another function called Print DateEuropean() that prints the date in European format.arrow_forwardHow would I implement the given function? Based on the given prompt?arrow_forward
- Change each one of these questions to now work using a function.  decide what the name of the function of each should be, how many parameters are required and what value needs to be returned. You’re no longer required to solve the problem - try to re-manage your code to be a function. Write a program that uses input to prompt a user for their name and then welcomes them. Enter your name: Chuck Hello Chuckarrow_forwardWrite a function called swap() that interchanges two int values passed to it by the callingprogram. (Note that this function swaps the values of the variables in the calling program,not those in the function.) You’ll need to decide how to pass the arguments.Create a main() program to exercise the function.arrow_forwardHow we can pass the function pointer as a parameter give example.arrow_forward
- Write a function that counts and returns the number of vowels in the string. (For the purposes of this exercise, we are talking about the standard 5 vowels -- A, E, I, O, U). Write a function that counts and returns the number of consonants in the string. Write a function that converts the string to all lowercase. Write a function that converts the string to all uppercase. Write the following functions. Each of these functions should have a single parameter -- accepting a c-style string as an argument. The function should only do what is specified (note that none of these functions do any output to the screen). Your functions should use const in the prototype wherever it is appropriate: Write the main function that offers a menu and allows the user to test the functions you have implemented. Program C++, must use c- stylearrow_forwardChange this question to work using a function. decide what the name of the function of each should be, how many parameters are required and what value needs to be returned. You're no longer required to solve the problem - try to re-manage your code to be a function. write a program which prompts the user for a Celsius temperature, convert the temperature to Fahrenheit, and print out the converted temperature. c = float (input ("What is the temperature in Celsius? '")) f = c* (9/5)+32 print ("The temperature in Fahrenheit is:”,f)arrow_forwardWrite a function in Racket that updates the year of a student, i.e. if the year is “Year1”, then update to “Year2”, if the year is “Year2”, then update to “Year3”, if the year is “Year3” then updated to “Graduated”. Make sure to write what the difference between mutable and immutable is.arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education