#include<iostream>
using namespace std;
int sum(int n)
{
int sum1=0;
for(int i=1;i<=n;i++)
sum1+= i*i+5;
return sum1;
}
int main()
{
int n;
cout<<"\nEnter the value of n:";
cin>>n;
cout<<"\nThe sum of the numbers is :"<<sum(n);
}
If you have any questions comment down and please upvote thanks
Write a C++ program using a function called sum that calculates the following summation: p=2+5 F...
1. Write a function to add two integers and return the summation. (Each box is 5 points.) a. Prototype a function: b. In main function; i. Take two integers from user: ii. Define 2 variables and call the function into main function to take the sum: Print the summation: C. Define the function to return the sum:
in c++ language 1.Re-write the following for loop statement by using a while loop statement: int sum = 0; for(int i=0;i<=1000;i++){ sum+=i; } 1 (b). Following is the main () function of a program. The program asks a user to enter 150 integers and print the largest integer user entered. int main() { int score, highest; //missing portion of the program return 0; } 1(c). Find the missing portion of the following code, so the...
Using c++.. 1. Write a program to find the sum(), Subtraction(), Multiplication(), Division() operations using Switch statement and functions. 2. Write a program to find the summation of N numbers. Use two functions. One function will take the input from user and the other will perform the summation from 1 to N. 3. Write a program to find the factorial of a number. Use two functions. One function will take the input from user and the other will perform the...
Student ID: 123 Write a C+ program with the following specifications: a. Define a C++ function (name it function_StudentlD where StudentID is your actual student ID number) that has one integer input (N) and one double input (x) and returns a double output S, where N S = n 0 and X2 is given by 0 xeVn n 0,1 Хл —{2. nx 2 n 2 2 m2 x2 3 (Note: in the actual quiz, do not expect a always, practice...
Using C++ language please not matlab a. Write a function, called SumOfDigits that is able to calculate the summation of a five-digit number. This function receives one integer parameter 'a', then returns the sum of 5 digits of the number. [2.5 marks] b. Write a function, called Armstrong that prints all Armstrong numbers in the range of 0 and 500. An Armstrong number of three digits is an integer such that the sum of the cubes of its digits is...
Done in C++ using visual studio 1. Write a program with one additional function called int[] reverseArray(int array). This function will receive an array from main and then reverse and should return the reversed array to the main to print out. Use a single array and a single loop, you’re are neither allowed to print out just in reverse order nor allowed to use another array variable to store the original array in reverse order. 2. Write a program which...
Write a C++ program that computes the following series: sum = 1/firstPrime + 2/secondPrime+…..+1/nthPrime Your program should prompt the user to enter a number n. The program will compute and display sum based on the series defined above. firstPrime: is 2 secondPrime: the first prime number after 2 thirdPrime: the third prime number …. nth prime: the nth prime number Your program must be organized as follows: int main() { //prompt the user to enter n //read n from the...
Using C++ Reference Parameters Assignment Write a program that asks the user for 3 numbers, sends the numbers to a function that calculates the sum and product and returns the sum and product to the main function. In the main function, use a cout statement to display the sum and product. * You are returning the multiple values sum and product.
I want to create a program that first calculate the summation from 1 to R. This code will computes the summation from 1 to R with single thread. #include <pthread.h> #include <unistd.h> #include <stdlib.h> #include <assert.h> #include <stdio.h> #define NuMBer_THREADS 2 #define R 1e4 long long sum = 0; // matrix multiplication is c = a * b; void calculatesum() { int i=1; for(i=1;i<=N;i++) { sum+=i; asleep(100); } } // Thread function // Each thread calculates the summation over (R...
Write a program that receives a positive integer n from the user and then calculates the sum below by using a loop. Your program needs to ask the user to re-enter a different number if the user enters a non-positive one. Display the result. 1 SUM 1 2 3 ... n x x n = = = + + + +