How to resolve the algorithm Sum and product of an array step by step in the Objective-C programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Sum and product of an array step by step in the Objective-C programming language
Table of Contents
Problem Statement
Compute the sum and product of an array of integers.
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Sum and product of an array step by step in the Objective-C programming language
Source code in the objective-c programming language
- (float) sum:(NSMutableArray *)array
{
int i, sum, value;
sum = 0;
value = 0;
for (i = 0; i < [array count]; i++) {
value = [[array objectAtIndex: i] intValue];
sum += value;
}
return suml;
}
- (float) prod:(NSMutableArray *)array
{
int i, prod, value;
prod = 0;
value = 0;
for (i = 0; i < [array count]; i++) {
value = [[array objectAtIndex: i] intValue];
prod *= value;
}
return suml;
}
You may also check:How to resolve the algorithm Self-describing numbers step by step in the Kotlin programming language
You may also check:How to resolve the algorithm Hello world/Text step by step in the XL programming language
You may also check:How to resolve the algorithm Ordered words step by step in the Lang5 programming language
You may also check:How to resolve the algorithm Law of cosines - triples step by step in the Delphi programming language
You may also check:How to resolve the algorithm String length step by step in the Bracmat programming language