Question

Define a function named *sumsin* that accepts double
precision variable *theta*, double precision variable
*alpha*, and unsigned integer *n*, and returns the
solution of

∑ k = 0 n sin ( θ + k α )

as a double precision value using an iterative structure (i.e. a
loop). Note the symbol for *theta* is θ, and the symbol for
*alpha* is α. Only show the function definition. Do not
write an entire program with a *main* function. Just write
the definition for function *sumsin*.

in C

Answer #1

Ans

code:-

double sumsin(double theta,double alpha,unsigned int n){

double sum=0.0;//to store result

//sum from k=0 to n

for(unsigned int k=0;k<=n;k++){

sum=sum + sin(theta+k*alpha);

}

return sum;

}

If any doubt ask in the comments.

Given the existence of two-dimensional array double
A[M][N], where M and N are #defined as the
number of rows and columns, respectively, define a function named
sqabsmax that accepts array A as an argument
(i.e. input parameter) and returns the square of the
maximum absolute value element in A. Use the
const qualifier if appropriate. Only show the function
definition. Do not write an entire program with a main
function. Just write the definition for function
sqabsmax.

Write a function that accepts an int array and the array’s size
as arguments. The function should create a copy of the array,
except that the element values should be reversed in the copy. 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 than 50) from standard input and then reads N
integers from a file named data into an...

Logic and Design Programming
In Syntax Pseudocode
Algorithm Workbench
1. Design a simple function named timesDozen that
accepts an Integer argument into a parameter named nbr. When the
function is called, it should return the value of its argument
multiplied times 12.
2. Assume that a program has two String variables named
alpha and bravo. Write - a pseudocode statement that assigns an all
uppercase version of alpha to the bravo variable.
Book name is Starting Out with Programming Logic...

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

Consider the C program (twoupdate) to
demonstrate race condition. In this assignment, we will implement
Peterson's algorithm to ensure mutual exclusion in the respective
critical sections of the two processes, and thereby eliminate the
race condition.
In order to implement Peterson's Algorithm, the two processes
should share a boolean array
calledflagwith two components and an integer
variable called turn, all initialized suitably. We
will create and access these shared variables using UNIX system
calls relating to shared memory – shmget,...

ADVERTISEMENT

Get Answers For Free

Most questions answered within 1 hours.

ADVERTISEMENT

asked 22 minutes ago

asked 38 minutes ago

asked 40 minutes ago

asked 49 minutes ago

asked 50 minutes ago

asked 1 hour ago

asked 1 hour ago

asked 1 hour ago

asked 1 hour ago

asked 1 hour ago

asked 1 hour ago

asked 2 hours ago