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

  Write script which declares and sets variable

Write the script which declares and sets a variable that's equal to total outstanding balance due. If that balance is greater than $10,000.00, the script must return the result set consisting of VendorName,

  Write program two functions to solve problem of university

Write the program with at least two functions to solve the following problem. The members of the board of a small university are considering voting for a pay increase for their 10 faculty members.

  Write program that asks user to enter five test scores

Write a program that asks the user to enter five test scores. The program should display a letter grade for each score and the average test score.

  Program to write variable declarations and function calls

Write a program whose main function is merely a collection of variable declarations and function calls. This program reads a text and outputs the letters, together with their counts.

  Create ajax-based product catalog

Create an AJAX-based product catalog which obtains its data from JSON files located on the server. The data should be separated into four JSON files.

  Write application to compute and show parking charges

Write down the application which computes and shows parking charges for each customer who parked in garage yesterday. You must enter hours parked for each customer.

  Design a driver to test implementation of program

Design a driver to test your implementation. Add various random elements to heap, and then remove & display smallest element.

  Write program that asks user for two digit number

Write program which asks user for two digit number and then prints English word for that number. Sample run: Enter a two-digit number: 45

  Binary search algorithm to search an array

The binary search algorithm that follows may be used to search array when elements are in order. This algorithm is analogous to following approach for finding name in telephone book.

  Computing first seven values of fibonacci number sequence

Write a program that uses a loop to compute the first seven values of the Fibonacci number sequence.

  Program to read the records until end of file

Zip code, county and number of boxes. The program should read the records until end of file is encountered and produce enough mailing labels for each order.

  Program display meal cost and tax amount

The program should then display the meal cost,taxAmt, and total bill respectively and use named constants Tax and tip to initialize the tax and the tip values.

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