In C Language: Numbers Process 1 (assigned to Programmer A) Process one for “pla
ID: 3689663 • Letter: I
Question
In C Language:
Numbers Process 1 (assigned to Programmer A)
Process one for “playing with numbers” is to take the collection of numbers entered by the user and to add every
2
nd and 3rd input value. For example, if the user had entered in these 6 numeric values,
10 20 20 7 20 12
The values in red would be the ones that would be in the summation (which the result in this example would be 72).
Constraint: The collection of numbers used in the calculation of this process must be contained inside the array
structure used in the “Capturing of Random Numeric Inputs Process”. No global variables are to be used
(but constant macros are allowed in the design). In addition, the calculated result of this process can not be
displayed within this process (e.g. it must be displayed by another process). Failure to follow this constraint for this
assignment will have an extremely negative impact to your grade for this assessment.
Explanation / Answer
#include <stdio.h>
int calSum(int n[])
{
int sum=0;
for(int i=0;i<sizeof(n);i++)
{
if(i%3!=0)
sum+=n[i];
}
return sum;
}
int main()
{
int n[]={10,20,20,7,20,12};
printf("Sum of 2nd and 3rd numbers : %d ",calSum(n));
return 0;
}