please help me write this c program. Write a program that reads an integer k fro
ID: 642300 • Letter: P
Question
please help me write this c program.
Write a program that reads an integer k from user and finds the number of elements that are divisible by k in the file assign4.txt. A number n is divisible by k if n = kx for some integer x > 0. You can use the mod operator % to test for divisibility. The file assign4.txt has integer values in the range [0,100 ]. You should use end-of-file controlled loop for this problem. Sample execution is given below.
Consider the file below
90 23 74 83
The output to be displayed on screen for the above file is
Explanation / Answer
#include <iostream>
using namespace std;
int main( )
{
int array[100];
int size;
cout << "Give the size of the array: ";
cin >> size;
for( int index = 0; index < size; index++ )
{
cout << "Give array[" << index << "]: ";
cin >> array[index];
}
system("PAUSE");
return 0 ;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.