Question: Please create a flow chart for the code below. PROGRAM C: OUTPUTTING DONE FROM WITHIN THE MAIN PROGRAM Program C: #include //declare the size as
Please create a flow chart for the code below.
PROGRAM C: OUTPUTTING DONE FROM WITHIN THE MAIN PROGRAM
Program C:
#include
//declare the size as 100.
#define size 100
// Definition of the function triangular()
// this function takes integer array and size variable n as arguments and integer array.
// finds the triangular value of each array and returns that array.
int triangular(int x[], int n, int tNo[]) {
//declare the variables.
int i, j;
// from array size 0 to n.
for (i = 0;i // initialise the array tNo[i] with 0. tNo[i] = 0; // initialise the array tNo[i] with 0. for (j = 1;j <= x[i];j++) { // add the value of j to value of tNo[i]. tNo[i] = tNo[i] + j; } //printf(" x[%d]=%d ===> tNo[%d]=%d",i,x[i],i,tNo[i]); } // return the updated array return tNo[size]; printf(" "); } //definition of the main function. int main() { //declare the variables. int i, n, a[size], tNo[size]; // prompt the user to enter the number of elements in the array printf("Enter the number of elements in the array: "); // read the value of the number of elements in the array scanf("%d", &n); // read the n value of the array using the for loop. for (i = 0;i // prompt the user to enter the each value of array from 0 to n-1. printf("Enter the values of the array element a[%d]: ", i); // read the values. scanf_s("%d", &a[i]); } // call the function triangular() by pasing the array a and size n as parameters and 2nd array. // assign the result of the function triangular() to the array tNo[size] . tNo[size] = triangular(a, n, tNo); // print the values of tNo[size] array. for (i = 0;i printf(" a[%d]=%d ===> tNo[%d]=%d", i, a[i], i, tNo[i]); } printf(" ");
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
