using c program Write a program to define a ID array of 1000

using c program

Write a program to define a ID array of 1000 element and fill it with a random values (using rand() function) between 1 and 1000 (integers), then searches and counts the number of values that can be exactly divided by 5. Finally print these values with their index numbers.

Solution

/* C Program to find sum of elements in a given array */
#include <stdio.h>
#include <stdlib.h>
#define MAX_SIZE 1000


int main()
{
int arr[MAX_SIZE];
  
for (int i = 0; i < MAX_SIZE; i++)
arr[i]= rand() % 1000 + 1;

   int count= 0;
for(int i=0; i<MAX_SIZE; i++)
{
/*
* verify the numbers divided by 5
*/
if(arr[i]%5==0)
{
printf(\"\ %d is found at index %d\", arr[i], i);
count++;
}
}
  
   printf(\"\ %d is number values that can be exactly divided by 5\", count);
  
}

using c program Write a program to define a ID array of 1000 element and fill it with a random values (using rand() function) between 1 and 1000 (integers), the

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site