answersLogoWhite

0


Best Answer

#include

using std::cin;

using std::cout;

using std::endl;

int main()

{

int sizeOfArray = 5;

int myArray[] = {0};

cout << "Enter elements of array" << endl;

for (int i = 0; i < sizeOfArray; i++)

{

cin >> myArray[i];

}

int sum = 0;

for (int j = 0; j < sizeOfArray; j++)

{

sum += myArray[j];

}

cout << endl << "Sum of " << sizeOfArray << " is: " << sum;

cin.get();

return 0;

}

User Avatar

Wiki User

14y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Write a program in C which has an integer array and its size as parameter and returns the sum of the values of the elements of the elements of the array Write a main function and show its usage?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

Different parameter passing methods with examples?

explain parameter passing methods c program


Write a program to subtract integer y from integer x?

x -=y;


What is meant by arguments in c?

Arguments appear in functions and in function calls. Arguments passed to a function are known as actual arguments. The arguments used by the function are known as the formal arguments. In C, all arguments are passed by value, such that the formal argument is a copy of the actual argument.


Explain the structure of c program with an suitable example?

Basic structure of a C program is /* Documentation section */ /* Link section */ /* Definition section */ /* Global declaretion section */ /* Function section */ (return type) (function name) (arguments...) void main() { Declaration part Executable part (statements) } /* Sub-program section */ (return type) (function name 1) (arguments...) (return type) (function name 2) (arguments...) . . . (return type) (function name n) (arguments...) Basic structure of a C program is /* Documentation section */ /* Link section */ /* Definition section */ /* Global declaretion section */ /* Function section */ (return type) (function name) (arguments...) void main() { Declaration part Executable part (statements) } /* Sub-program section */ (return type) (function name 1) (arguments...) (return type) (function name 2) (arguments...) . . . (return type) (function name n) (arguments...)


How do you write a visual basic program to sum the odd number digits of a 12 digit code using division and Mod and while loops?

Function sum_odd_digits(ByVal number As Integer) As Integer Dim digit As Integer sum_odd_digits = 0 While number &lt;&gt; 0 digit = number Mod 10 If digit And 1 Then sum_odd_digits = sum_odd_digits + digit number = number / 10 End While End Function

Related questions

Why and when should programmers use a constant reference parameter?

when we use that parameter as a global parameter and we used that parameter through out the program without changing


Can you write a program without specifying the prototype of any function?

You can write a program without specifying its prototype when the function returns an integer.If the prototype is not mentioned the compiler thinks that the return type of the function used is integer.When making program which return integer you can ignore writing the protoype.


Different parameter passing methods with examples?

explain parameter passing methods c program


What is the code of a c program that will read in a positive integer value and determine If the integer is a prime number and If the integer is a Fibonacci number?

see the program


Write a program in vb to check whether a no is prime or not?

Function isPrime(ByVal n As Integer) As Boolean If n &lt; 2 Then Return False End If Dim sqrtn As Integer = Math.Sqrt(n) + 1 For i As Integer = 2 To sqrtn If (n Mod i) = 0 Then Return False End If Next Return True End Function


What is a PHP file?

A PHP file is a text file containing code to be run on a webserver by a program called php. It's the most used dynamic page script engine as it is free and open source.Use the fopen() function to open files in PHP. The first parameter of this function is the file to be opened and the second parameter specifies in which mode the file should be opened


How can I write a program to display prime numbers from 1 to 100?

Write a function that implements an algorithm that checks to see if a particular integer is prime (returning a boolean). Write a program that uses that function on each number from 1 to 100, and if true, displays that number.


Write a program to subtract integer y from integer x?

x -=y;


How do you round a number 1 decimal place program?

Many computer programs and programming languages have a built-in round function; read the documentation. If there is none, you can also: 1. Multiply by 10 2. To round to an integer: add 0.5 to the result, then apply the integer function 3. Divide the result by 10 again.


What is meant by arguments in c?

Arguments appear in functions and in function calls. Arguments passed to a function are known as actual arguments. The arguments used by the function are known as the formal arguments. In C, all arguments are passed by value, such that the formal argument is a copy of the actual argument.


Explain the structure of c program with an suitable example?

Basic structure of a C program is /* Documentation section */ /* Link section */ /* Definition section */ /* Global declaretion section */ /* Function section */ (return type) (function name) (arguments...) void main() { Declaration part Executable part (statements) } /* Sub-program section */ (return type) (function name 1) (arguments...) (return type) (function name 2) (arguments...) . . . (return type) (function name n) (arguments...) Basic structure of a C program is /* Documentation section */ /* Link section */ /* Definition section */ /* Global declaretion section */ /* Function section */ (return type) (function name) (arguments...) void main() { Declaration part Executable part (statements) } /* Sub-program section */ (return type) (function name 1) (arguments...) (return type) (function name 2) (arguments...) . . . (return type) (function name n) (arguments...)


What is the three major parts of a pascal program?

-var,const,uses declaration part could start with uses in case of a declaration for a libr ex. (uses crt) var,const refers to those used in the main probram -functions,procedures declaration part declaration of the function/procedure + content ex. (function one(x:integer):integer; var y:integer; begin ...... one=....(integer expresion for return value); ...... end;) the procedures don't have any return value (:integer) -main program begin ........ end.