How do I create a program with a for loop for evaluating summations: it’s inputs should be a function, k, and n. The program adds from i=k to i=n the value of f(i).
Here I am providing the answer for the above question:
Code:
#include <stdio.h>
void takeInput(int *k,int *n)
{
int i,j;
printf("Enter k value:");
scanf("%d",&i);
printf("Enter n value:");
scanf("%d",&j);
*k=i;
*n=j;
}
int main()
{
int k,n,sum=0;
takeInput(&k,&n);
for(int i=k;i<=n;i++)
{
sum=sum+i;
}
printf("Sum of elements from k to n is:%d",sum);
return 0;
}
Screenshot:

Output:

Hoping that the above answer will help you...Please comment for further assistance...Thank you...
How do I create a program with a for loop for evaluating summations: it’s inputs should...
The problem
Write a program that inputs two integers n and k, where n>=k.
Your program should calculate the number of different ways that k
bishops could be placed on an nXn chessboard. Structure your
program using the backtracking scheme that we have used for the
eight queens problem. What needs to be modified is the “OK”
function.
Input
Your main program should loop asking the user for values of n
and k.
Output
Each time through the loop, output...
I should use the array and loop to create a java program
according to the instruction, but I have no idea how to do
it.
Introduction This lab assignment continues to give you practice using loops, particularly loops with variable termination conditions, and it also provides you an opportunity to use one-dimensional arrays. Recall that an array is used to store a collection of data. The data can be values of Java primitive data types or else objects (for instance,...
using C++ Write a program that: a) Inputs an integer n from the keyboard where n<=100. If n is out of range then print out an error message and ask for another input. This process repeats until a valid value for n is obtained. b) Inputs two 1D arrays of doubles A and B (of size n) from the keyboard. c) Inputs an integer k (from 1 to 3) from the keyboard. d) If k = 1 then it calculates...
How do I make a python function that takes 5 user inputs then sorts that from largest to smallest, smallest to largest, adds them and an average.
How do I make this program run the same using a do while loop instead of the for loop? I'm supposed to replace the for loop with a do-while. Also, how would i replace it with a while loop? #include void main(void) { int n, sum, product, i; printf("n?\n"); scanf("%i", &n); printf("You entered %i\n", n); sum = 0; product = 1; for (i=1; i<=n;i++) { if((i%3!=0) && (i%5!=0)){ sum = sum + i; product = product * i;} ...
1) Create a matlab function that calculates:
for
Name your function TwoVarFunc :
The inputs should be in the same order:
xmin
xmax
ymin
ymax
N: n is the number of elements in the vector x and y
The ouputs should be in the same order:
f_xy: is the calculated array f(x,y)
f_xyMAX: should be the the maximum value of the function
f(x,y).
Hint: to create vectors x and y look up the matlab built-in
function linspace()
Hint 2: To...
create a Java class ShiftCipher The program ShiftCipher should take two inputs from the terminal. The first should be a string of any length which contains any type of symbol (the plaintext). The second will be a shift value which should be between 0 and 25 inclusive (though you may design your program to be resilient to shifts beyond this value). The program should print the cipher text, in which each of the alphabetic characters in the string is shifted...
IN MIPS Create a program that, given two inputs a and b, will output the following: • (a*b+b*3) Create a function that will perform this calculation, and use $a0 and $a1 as the argument registers, and $v0 for the return value. Ensure that you are able to call this function with additional statements before and after the call: for example, you may be asked to place an addi a, a, 3 call before the function is called, or to calculate...
Temperature Converter Create a temperature conversion program that will convert the following to Fahrenheit: Celsius Kelvin Newton Your program should take a character which represents the temperature to convert from and a value to be converted to using the following specification: C - Celsius K - Kelvin N - Newton In addition your program should take in the following character to exit the program: X - eXit the program The numeric input for your program should be of type double....
C++
4. Write a program that inputs 5 scores using a do while loop and asks a user whether to continue or not ("yes" or "no il pressed you continues if pressed no' terutiinales) then calculates the average. 5. Make a program calculates sales for its division and quarterly earnings and show the total sum. Use 5 by 2 array matrix 6. This is an extra credil questioni Produce a program that displays by decreasing or decremeniting by 4 starting...