Question

**In this example you are allowed to use from the C
standard library only functions for input and output (e.g.
printf(), scanf())**

Complete the following functions using C programming language:

Calculate the value of π from the infinite series:

π = 4 – 4/3 + 4/5 – 4/7 + 4/9 – 4/11 + …

Complete the double Q4(intQ4_input) function which reads a positive integer Q4_input as an input parameter and calculates the value of π by adding up the first Q4_input terms of the above series. You must return the calculated value as a double

Answer #1

double Q4(int Q4_input){ int i, d = 1; double result = 0; for(i=0;i<Q4_input;i++){ if(i%2==0){ result = result + (1.0/d); } else{ result = result - (1.0/d); } d += 2; } return result*4; }int main(){ int n; printf("Enter input: "); scanf("%d",&n); printf("Result: %lf\n",Q4(n)); return 0; }

In this example you are allowed to use from the C
standard library only functions for input and output (e.g.
printf(), scanf())
Complete the following functions using C programming
language:
a) Complete the int Q7a(intQ7_input) function takes a
seven-digit positive integer as input and returns it reversed. For
example, if the integer is 9806593, the program should print
3956089. You are not permitted to use any function of C standard
library other than scanf()and printf().You are not permitted to use...

In this example you are allowed to use from the C
standard library only functions for input and output (e.g.
printf(), scanf())
Complete the following functions using C programming
language:
intQ1_for()
intQ1_while()
intQ1_do()
To compute the sum of all numbers that are multiples of 4,
between 30 and 1000, in 3 different ways: with a for loop, a while
loop and a do-while loop, accordingly. After each loop print the
value. Return the total sum at the end of each...

In this example you are allowed to use from the C
standard library only functions for input and output (e.g.
printf(), scanf())
Complete the following function using C programming
language:
Complete the function intQ3(floatQ3_input) that takes a
student’s average as an input, which is a floating-point value, and
returns:
4 if the average is in the range 90-100,
3 if it is in the range 80-89,
2 if it is in the range 70-79,
1 if it is in the...

In this example you are allowed to use from the C
standard library only functions for input and output (e.g.
printf(), scanf())
For this exercise you should be able to write a logical
expression (i.e., with logical operators) which checks if some
integer x consists of exactly 5 digits. Ex: 30498 and -14004 are
5-digit numbers, while 1018, -2 and 46 are not.
Complete the intQ2(intQ2_input) function that takes an input
integer parameter and returns 1 if the number is...

In this example you are allowed to use from the C
standard library only functions for input and output (e.g.
printf(), scanf())
Complete the following functions using C programming
language:
A positive integer number is said to be a perfect number if its
positive factors, including 1 (but not the number itself), sum to
the number. For example, 6 is a perfect number because 6=1+2+3.
Complete the int Q6(intQ6_input, int perfect[])function that
determines all perfect numbers smaller than or equal...

One way in which computers can compute the values of functions
like the sine, cosine, logarithm and so on is to use a power series
expansion. This is an infinite series from which the first few
terms are calculated and used to find an approximate value for the
function. The series expansion for the exponential function is : ex
= exp(x) = 1 + x + x2 /2! + x3/3! + x4 /4/! + … + xn /n! + …...

Please write the code
in Python.
Write a
program/function in any Object-Oriented programming language that
will implement Queue Abstract Data Type with the following
functions/methods. Any build-in/pre-defined Queue
function/library (e.g., java.util.Queue in Java) is
NOT allowed to use in your code.
push(Element): insert the
input Element (e.g., String or Integer in Java) to the end
of the queue.
pop(): remove
the head element of the queue and print the head element on
screen.
count(): return the total number of
elements in the queue...

You will write a program that loops until the user selects 0 to
exit. In the loop the user interactively selects a menu choice to
compress or decompress a file. There are three menu options: Option
0: allows the user to exit the program.
Option 1: allows the user to compress the specified input file
and store the result in an output file.
Option 2: allows the user to decompress the specified input file
and store the result in an...

Task #4 Calculating the Mean
Now we need to add lines to allow us to read from the input
file and calculate the mean.
Create a FileReader object passing it the filename.
Create a BufferedReader object passing it the FileReader
object.
Write a priming read to read the first line of the file.
Write a loop that continues until you are at the end of the
file.
The body of the loop will:
convert the line into a double value...

This is C programming assignment. The objective of this homework
is to give you practice using make files to compose an executable
file from a set of source files and adding additional functions to
an existing set of code. This assignment will give you an
appreciation for the ease with which well designed software can be
extended. For this assignment, you will use both the static and
dynamic assignment versions of the matrix software. Using each
version, do the following:...

ADVERTISEMENT

Get Answers For Free

Most questions answered within 1 hours.

ADVERTISEMENT

asked 14 minutes ago

asked 48 minutes 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

asked 2 hours ago

asked 2 hours ago

asked 2 hours ago

asked 2 hours ago