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;
}
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.
|