Question

Write a Main function and a Function to compute and print the sine and cosine values...

Write a Main function and a Function to compute and print the sine and cosine values of the array A elements which are angles in degrees.
Within the MAIN function:
Declare a float array A to hold 50 angles in degrees.
Initialize array A elements from the standard input.
Pass the array A to the function as an argument.
Within the function:
Read array A elements and compute and print the sine and cosine values of the array A elements which are greater than 0 and less than 120 degrees? ( Pi=3.14)
0 0
Add a comment Improve this question Transcribed image text
Answer #1

tri.c :

#include <stdio.h>
#include <math.h>
#define PI 3.14159265
void trigo(float A[]);
void main()
{
int i;
float A[50];

printf("Enter angles in degrees\n");
for(i=0;i<50;i++)
{
scanf("%f",&A[i]);
}
trigo(A);
}
void trigo(float A[])
{
int i;
double c,s,val;
val = PI / 180;
for(i=0;i<50;i++)
{
if((A[i]>0) && (A[i]<120))
{
s = sin(A[i]*val);
c = cos(A[i]*val);
printf("The sine of %f is %lf\n",A[i],s);
printf("The cosine of %f is %lf\n",A[i],c);
}
}
}

//compile using $ gcc tri.c -lm

Add a comment
Know the answer?
Add Answer to:
Write a Main function and a Function to compute and print the sine and cosine values...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • I need a simple program in C language that calculates the values of Sine, Cosine, and...

    I need a simple program in C language that calculates the values of Sine, Cosine, and Tangent of values given in degrees. It has to be a range of values between 0 and 360(integer values). The output should be a table of values showing Sin, Cos and Tan values. The complete computation and printing of the table must be done inside a function. The function also returns to the main program with 3 output arguments: It also needs to show...

  • Q 3-) (30 points) Write a C program (MAIN function) and a FUNCTION to create and...

    Q 3-) (30 points) Write a C program (MAIN function) and a FUNCTION to create and print the transpose of a two- dimensional array. Within C program (the MAIN function); Declare a two- dimensional 3X2 integer array A and initialise with the values (1,2), (3,4), (5,6), declare also a two-dimensional 2X3 integer array B and initialise it with zero. Call the FUNCTION and pass arrays A and B to the FUNCTION as arguments. Print the array A and its transpose....

  • Take my hyperbolic sin/cos recursive function place the angle on a sine or cosine stack that represents a call to the si...

    Take my hyperbolic sin/cos recursive function place the angle on a sine or cosine stack that represents a call to the sine or cosine. When the program returns, examine the stack for how many times the hyp sine was called and how many times hyp sine/cosine was called vs. the value you inputted into the program. Put the results in a table. Range of values from -1 to 1 in .1 radian increments. Does the number of function calls agree...

  • Using C++ And #include <stdio.h> #include <stdlib.h> #include <time.h> a) Write a main function and declare...

    Using C++ And #include <stdio.h> #include <stdlib.h> #include <time.h> a) Write a main function and declare an array with 100 elements. b) In the main, initialize each number in the array to be a random number between 100 and 200. c) Write a function that returns the value of the smallest number in the array. Call this function from the main and print the result. d) Declare a 2D array with dimensions 2x2 and initilize the array, as follows: [1,...

  • Write a program that will do the following. The main function should ask the user how...

    Write a program that will do the following. The main function should ask the user how many numbers it will read in. It will then create an array of that size. Next, it will call a function that will read in the numbers and fill the array (fillArray). Pass the array that was made in themain function as a parameter to this function. Use a loop that will read numbers from the keyboard and store them in the array. This...

  • Implement the sort procedure from Assignment 18 as a void function. Pass the address of the...

    Implement the sort procedure from Assignment 18 as a void function. Pass the address of the first array element to the function along with the number of elements in the array. Use pointers in your function to reference the array elements. The sort function should do nothing but sort the elements of the array. DO NOT pass the entire array as an argument to the function. As in Assignment 18, print out the array before and after sorting. Use the...

  • (C++) Write a function that accepts an int array and the array’s size as arguments. The function...

    (C++)Write a function that accepts an int array and the array’s size as arguments.The function should create a new array that is twice the size of the argument array.The function should copy the contents of the argument array to the new array, and initialize the unused elements of the second array with 0.The function should return a pointer to the new array.Demonstrate the function by using it in a main program that reads an integer N (that is not more...

  • Write a program that performs the following operations on a one dimensional array with 50 unsigned...

    Write a program that performs the following operations on a one dimensional array with 50 unsigned integers. The main program will initialize the array, print the array values to the screen and then call a function that will determine and print the maximum and minimum values. •Declare the array and any other variables. •Use a loop to initialize the array with 50 random integer values between 0 and 99 using the rand() function. (number = rand() % 100;) •Using cout...

  • Question 4.4: Write an overloaded function of function area with 3 (float) parameters. This function should...

    Question 4.4: Write an overloaded function of function area with 3 (float) parameters. This function should calculate and print out the product of the 3 parameters. Question 4.4: Write the main function to test question 4.1, 4.2, 4.3, 4.4. Your main function should ask if the user want to calculate the area of a rectangle or a circle or a triangle then print out the result accordingly. (Use switch structure). For example: Please enter (r) for rectangle, (t) for triangle,...

  • Write a C++ function, lastLargestIndex that takes as parameters an int array and its size and...

    Write a C++ function, lastLargestIndex that takes as parameters an int array and its size and returns the index of the "last occurrence" of the largest element in the array. Include another function to print the array. Also, write a program to test your function. [HINTS) Create an array of size 15 in the main function and initialize it with the values shown in the below sample output. Pass the array and its size to function lastLargestindex; function lastLargestindex returns...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT