Write a c function called values that returns void

Assignment Help Programming Languages
Reference no: EM13164598

Write a C function called values that returns void and takes two double precision arguments (called a and b) and one double precision array argument. The array argument has two rows and NDATA columns where NDATA is a symbolic constant. The function returns values using the array argument. On return from a function call, the first row of the array argument has NDATA values of x uniformly spaced between a and b inclusive and the second row has the corresponding values generated by the Bspline function of the previous exercise. Provide a main program to generate and print the array of values created by the function. Use NDATA set to 30, a=-2.5, b=3.0 (2) Write a C function called plot that takes the array generated in (1) as its first argument and produces a two dimensional character array with NR rows and NDATA columns where NDATA and NR are symbolic constants. This character array is the second argument of the function plot. This character array contains a plot of the data generated in (1) with all blanks in the array except where the function values are present and in these locations the character '*' is displayed. Arrange scaling so that the plot uses all rows of the display. The maximum y value(s) are displayed in row 0 of the character array. The main program prints this character array. (Note you will need to find maximum and minimum y values in the array of data to generate the proper scaling in the y direction). The '*' characters are placed at the nearest location as determined by conversion to an

integer (truncation, not rounding). Test with NDATA set to 30, NR set to 40, a=-2.5, b=3.0.
In addition to the above requirements, also satisfy the following:
1. Use only ONE C program for (1) and (2).

 

MY CODE

#include
<stdio.h>
#include
<math.h>
double
Bspline(double);
double
y=3.0;
double
x=-2.5;
int
main() {
printf(
"Giovanni Piniccilo\n");
for (x; x<=3.0; x= double (x+3.0/29.00)) {
Bspline(x);
printf(
"x= %10.6f y= %10.6f\n",x,y);
}
}
double
Bspline(double x){
if
(x >= -2&&x <-1){
return
(y= (1.0/4.0)*(x+2.0)*(x+2.0)*(x+ 2.0));
}
else
{
if
(x >= -1&&x <0){
return
(y=(1.0/4)+ (3.0/4)*(x+1)+(3/4)*(x+1)*(x+ 1)-(3/4)*(x+1)*(x+1)*(x+1));
}
else
{
if
(0 <= x&&x <1){
return
(y=(1.0/4)+ (3/4)*(1-x)+(3/4)*(1-x)*(1-x)- (3/4)*(1-x)*(1-x)*(1-x));
}
else
{
if
(1 <= x && x <2){
return
(y= (1.0/4)*(2-x)*(2-x)*(2-x));
}
else
{
return
(y=0.0);
}}}}
return
(0);
}
//Array
#define
size 30
int
sum(int x [][size];
int
main(){
int y[2][size]={{1,2,3,4},{5,6,7,8},{9,10,11,12};
printf(
"sum=%d\n", sum (y));
return 0;
}
int sum (int x[][size]){
int i,j, sum=0
for(i=0;i<3;i++){
for(j=0; j<size; j++){
sum += x[i][j];
}
}

return sum;
}

 

 

Reference no: EM13164598

Questions Cloud

Program to keep track of the participants in a triathlon : Create a program to keep track of the participants in a triathlon. Your program will keep track of the times in three events: Running, Swimming, and Biking. Your program will calculate who is the winner in the Male category and the Female category..
Write an abstract class carbon footprint : Using an abstract class with only pure virtual functions, create three small classes unrelated by inheritance---clases Building, Car and Bicycle.
Calculate the geometric mean of numbers : Write a program to calculate the geometric mean of numbers entered by a user. The program should prompt the user to enter numbers and continue to accept the numbers until the user enters 999.
Make a fourth button called special : Make a fourth button called "special" that does something else notdescribed in the assignment, such as change the background color.
Write a c function called values that returns void : Write a C function called values that returns void and takes two double precision arguments (called a and b) and one double precision array argument.
Trojan horse defense : Using your favorite search engine, look up "Trojan Horse Defense". How can it be used to question the conclusions drawn from a forensic investigation? Site a case where it was used.
Write a java program that uses a search tree of strings : Write a Java program that uses a search tree of strings to sort text lines in alphabetic order. You may choose how you de?ne alphabetic order as long as there is some sense in the de?nition. You may also choose what kind of tree you use.
Fragmentation on a storage device : Fragmentation on a storage device could be eliminated by re-compaction of the information. Typical disk devices do not have relocation or base registers (such as are used when memory is to be compacted)
Program that allows a user to input coordinates : In Java make a program that allows a user to input coordinates as to make a Hexagon via an array, and my professor has set the standards of: Write a class Polygon which draws a hexagon for a set of numbers given by the user.

Reviews

Write a Review

Programming Languages Questions & Answers

  Program to calculate the electricity bill

Write a program to calculate the electricity bill. The rates of electricity per unit are as follows: If the units consumed are equal or less than 100, then the cost is Rs 8/- per unit.

  Write function which take parameter-string and returns vowel

Write function which takes as parameter and string and returns the vowels (a, e, i, o, u). Function prototype should look like: void countVowels(string str, int& aCt, int& eCt, int& iCt, int& oCt, int& uCt);

  Develop class templates for administrative employees

Develop classes or class templates for the following: Administrative Employees are paid a salary, but they also receive a bonus at regular intervals during the year. Add a class "Administrator" to the Employee class hierarchy.

  Write program which prints question and reads user input

Write the program which prints question "Do you want to continue?" and reads user input. If user input is "Y", "Yes", "OK", "Sure", or "Why not?", print out "OK".

  Implicit unsafe type conversions-statements and expressions

Write a report using APA format for references that researches the definition of the language with respect to implicit unsafe type conversions in both assignment statements and expressions.

  Explain the problem of storing data in matrix

Each such element is accompanied by its two indexes (the row and the column). Explain in what ways such structure is similar to and/or different than list.

  Write down public static method using public interface

Using only public interface of UnorderedLinkedList class, write down a method: public static void reverse(UnorderedLinkedList staff) that reverses the entries in a linked list.

  Design program which models the worms behavior

Design a program which models the worms behavior in the following scenario: A worm is moving toward an apple. Each time it moves, the worm cuts the distance between itself and the apple.

  Program-customer-s names phone numbers in alphabetical order

Load file into parallel arrays and display list of customers' names and phone numbers in alphabetical order.

  Write program that compute the amount person earn

Write a program which computes the amount a person would earn over period of time if his or her salary is one penny the first day, two pennies second day.

  How to update web pages using navy for unvisited link

The Marketing Director at Steel Solutions is unhappy that links on company Web page appear in blue. She has asked you to update Web pages to use navy for unvisited link.

  Computing return value after execution of program

Compute return value of Antony after its execution?

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