write a program to display the sum and average of numbers from 100 to 200 using pointers
Answers
Answer:
I dont knowww
Step-by-step explanation:
Concept:
A pointer is an object that stores a memory address in several programming languages used in computer science. This could be a different value stored in computer memory or, in some situations, hardware that is memory-mapped. A variable is a way whose value is either another variable's location or the direct address of a program memory. A pointer must be declared before it may be used to store any variable address, just like any variable or constant.
Given:
Create a programme that uses pointers to display the average and sum of values between 100 and 200.
Find:
Find the program for the given question
Program:
Blocks of memory that are dynamically allocated are managed and stored using pointers. Data objects or arrays of objects are stored in such blocks. The heap or free store, which is a memory space provided by the majority of structured and object-oriented languages, is where objects are dynamically allocated.
#include<stdio.h>
void main()
{
int size, sum=0;
printf("specify the array size = ");
scanf("%d", &size);
int array[size];
int *parray = array;
printf("Itemize the Array = ");
for (i = 0; i < size; i++)
{
scanf("%d", parray + i);
sum = sum + *(parray + i);
}
float average = (float)sum / size;
printf("The Sum of Array Items = %d\n", sum);
printf("The Array Items' Average = %.2f\n", average);
}
output:
the array size should be 7
the array of Items 2 19 33 45 10 98 77
The array's total items equal 284
The median of the array's items is 40.57.
#SPJ2