Write program to evaluate any function of order five or less

Assignment Help C/C++ Programming
Reference no: EM131395804

Introduction to Programming Assignment- Basic C

Introduction

In this assignment you will write small C programs. Each C program should be submitted as a standard C source code file. You can submit your files separately or zipped together into one file.

Please note that the computer program should comply with the commenting and formatting rules as has been done in class. For example, there should be a header for the whole program that gives the author's name, class name, date, and description. End braces should be commented, and there are alignment and indenting requirements as discussed. Please ask if you have any questions.

Program #1

Write a program for each case (a to c). Each program will ask the user for an integer number n and a character ch. The output generated depends on the value of n and the character ch.

For example, say that n = 5 and ch = ‘*':
(5 points) Program 1.a) will display

*
***
*****
*******
*********
Program 1.b) will display:

*
* *
* * *
* * * *
* * * * *

Notice: the number of spaces between each ‘*' is increasing at each row.

Program 1.c) will display 1* 2* 3* 4* 5*

2* 3* 4* 5* 1*
3* 4* 5* 1* 2*
4* 5* 1* 2* 3*
5* 1* 2* 3* 4*

Program #2

Write a program to evaluate any function of order 5 or less at a given interval [xmin, xmax], and display a table with the values of x, and f(x).

INPUT: The program will ask the user to enter

a) The function's order f_order.

• If the order is greater than 5 or smaller than 1, an error message should be displayed and the program ends,
• Otherwise, the program will ask for the respective coefficients.

b) The values for xmin and xmax

• If the value for xmax is smaller or equal to xmin, an error messages should be displayed and the program will end.

Assume that f(x) is defined as f(x) = ax5 + bx4 + cx3 + dx2 + ex + f.

If the f_order is:

• 5, then the program will ask for coefficients a, b, c, d, e and f;
• 4, then the program will ask for coefficients b, c, d, e and f;
• 3, then the program will ask for coefficients c, d, e and f;
• 2, then the program will ask for coefficients d, e and f;
• 1, then the program will ask for coefficients e and f;

OUTPUT:

The output is formatted as a table. The first column will display the values of x, and the second column the values of f(x). The first row should always have the value xmin for x, and f(xmin) for f(x). Last row should always have the value xmax for x, and f(xmax) for f(x).

The table will look like:

x f(x)
-----------|-------------------
xmin | f(xmin)
xmin +dx | f(xmin+dx)
xmin +2dx | f(xmin+2dx)
xmin +3dx | f(xmin+3dx)
xmin +4dx | f(xmin+4dx)
. |
. |
xmax | f(xmax)
------------------------------

Where

• xmin is the value entered by the user, and
• f(xmin) is the result of evaluating the function when x=xmin
• dx is the increment size, and is defined by ???? = (???????? - ????????)/10

Use 2 decimals for f(x) values.

Table formatting: 10 points
Function evaluation: 20 points

Include a report in a Word file that shows

a) List all the variables, constants(literals, symbolic and named) in your program 2). (5 points)

*Optional [Extra Points]:

- Include in the word file, plots of f(x) in the range [-13,13] for each valid value of f_order (10 points). You pick the coefficients for each case.

If you do not have access to MATLAB you can also use OCTAVE or SciLab.

You are allowed to use the function float pow( float, int), found in <math.h>, to calculate the powers of x.

Topics covered: Basic C, Expression evaluation, operators, flow control statements (loops, switch-case, if-else, etc) and MATLAB as optionals.

Attachment:- Basic_C.pdf

Reference no: EM131395804

Questions Cloud

Why did the participants conform so readily : Why did the participants conform so readily? When they were interviewed after the experiment, most of them said that they did not really believe their conforming answers, but had gone along with the group for fear of being ridiculed or thought "pe..
Identify three cost classifications used in decision making : Identify three cost classifications used in decision making and provide examples of each. Hint: not manufacturing cost?
Employers to actively recruit engineers : 1. Are there any ethical justifications for employers to actively recruit engineers from competing organizations? 2. The engineering management ladder tends to lead to higher career earnings than the engineering technical ladder. Is this fair?
Create a program to find all prime numbers between 1 and 100 : Write another loop that lists the primes you found. You might check your result by comparing your vector of prime numbers with primes. Consider 2 the first prime.
Write program to evaluate any function of order five or less : CS1325- Write a program to evaluate any function of order 5 or less at a given interval [xmin, xmax], and display a table with the values of x, and f(x).
Dessert means something such as pie or cake or cookies : Determine whether the following are demonstrative definitions, enumerative definitions, definitions by subclass, synonymous definitions, etymological definitions or operational definitions.- "Dessert" means something such as pie, cake, cookies, o..
Select a health-related topic applicable to your practice : Select a health-related topic applicable to your practice setting and formulate a clinical question using the PICO (T) format. Identify key terms that you will use to search the literature, based on the PICO (T) elements. Search for information ..
Write a program that plays the game rock paper scissors : If you build the vector into the program, it will always play the same game, so maybe you should let the user enter some values. Try variations to make it less easy for the user to guess which move the machine will make next
Synonymous definitions or operational definitions : Whether the following are demonstrative definitions, enumerative definitions, definitions by subclass, synonymous definitions, etymological definitions or operational definitions.- "Painting" means something like da Vinci's Mona Lisa, van Gogh's St..

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Create program that uses functions and reference parameters

Create program that uses functions and reference parameters, and asks user for the outside temperature.

  Write a program using vectors and iterators

Write a program using vectors and iterators that allows a user to maintain a personal list of DVD titles

  Write the code required to analyse and display the data

Calculate and store the average for each row and column. Determine and store the values for the Average Map.

  Write a webservices application

Write a webservices application that does a simple four function calculator

  Iimplement a client-server of the game

Iimplement a client-server version of the rock-paper-scissors-lizard-Spock game.

  Model-view-controller

Explain Model-View-Controller paradigm

  Design a nested program

How many levels of nesting are there in this design?

  Convert celsius temperatures to fahrenheit temperatures

Write a C++ program that converts Celsius Temperatures to Fahrenheit Temperatures.

  Evaluate and output the value in the given base

Write C program that will input two values from the user that are a Value and a Base with which you will evaluate and output the Value in the given Base.

  Design a base class shape with virtual functions

Design a base class shape with virtual functions

  Implementation of classes

Implementation of classes Chart and BarChart. Class barChart chould display a simple textual representation of the data

  Technical paper: memory management

Technical Paper: Memory Management, The intent of this paper is to provide you with an in depth knowledge of how memory is used in executing, your programs and its critical support for applications.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd