Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask C/C++ Expert


Home >> C/C++

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 , 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

C/C++, Programming

  • Category:- C/C++
  • Reference No.:- M92205619

Have any Question?


Related Questions in C/C++

Question 1find the minimum and maximum of a list of numbers

Question: 1. Find the Minimum and Maximum of a List of Numbers: 10 points File: find_min_max.cpp Write a program that reads some number of integers from the user and finds the minimum and maximum numbers in this list. Th ...

Assign ment - genetic algorithmin this assignment you will

ASSIGN MENT - GENETIC ALGORITHM In this assignment, you will use your C programming skills to build a simple Genetic Algorithm. DESCRIPTION OF THE PROGRAM - CORE REQUIREMENTS - REQ1: Command-line arguments The user of yo ...

There are several ways to calculate the pulse width of a

There are several ways to calculate the pulse width of a digital input signal. One method is to directly read the input pin and another method (more efficient) is to use a timer and pin change interrupt. Function startTi ...

What are the legal requirements with which websites must

What are the legal requirements with which websites must comply in order to meet the needs of persons with disabilities? Why is maximizing accessibility important to everyone?

1 implement the binary search tree bst in c using the node

1. Implement the Binary Search Tree (BST) in C++, using the Node class template provided below. Please read the provided helper methods in class BST, especially for deleteValue(), make sure you get a fully understanding ...

Project - space race part a console Project - Space Race Part A: Console Implementation

Project - Space Race Part A: Console Implementation INTRODUCTION This assignment aims to give you a real problem-solving experience, similar to what you might encounter in the workplace. You have been hired to complete a ...

Assignment word matchingwhats a six-letter word that has an

Assignment: Word Matching What's a six-letter word that has an e as its first, third, and fifth letter? Can you find an anagram of pine grave. Or how about a word that starts and ends with ant (other than ant itself, of ...

Why do researcher drop the ewaste and where does it end

Why do researcher drop the ewaste and where does it end up?

Software development fundamentals assignment 1 -details amp

Software Development Fundamentals Assignment 1 - Details & Problems - In this assignment, you are required to answer the short questions, identify error in the code, give output of the code and develop three C# Console P ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As