LAB8.DAT IS LISTED BELOW
154 -6 279 215 404 391 -166 199 -302 -469 244 0 -20 405 110 118 359 305 77 -317 -260 387 -471 -10 -332 479 213 0 -29 -440 182 -458 -429 22 -403 318 318 222 -350 160 19 473 149 300 -46 -68 325 -417 -367 -327 -109 331 303 -440 -101 27 -83 157 128 -208 -68 -485 484 -333
-394 -128 -302 -10 -161 452 420 -447 238 -231 -77 48 443 -82 483 -199 201 166 39 198 167 -322 -372 499 -329 -467 61 382 169 -310 -131 -39 482 -344 356 145 -124 -309 -72 -18 -379 90 -274 -115 83 -248 -210 117 -235 324 483 230 -156 84 -392 406 380 318 -239 94 -477 -75 -187 -339
-321 -77 -406 99 -29 196 200 139 -466 -431 -180 31 154 -92 320 218 469 31 -175 -394 111 279 -77 -409 -234 -346 -219 -60 27 -43 375 18 444 138 458 -259 176 -211 172 195 -432 -245 -276 168 344 -156 281 175 -493 102 -113 416 -499 -38 -76 -39 270 -178 285 -29 -464 -324 222 -27
-347 -159 107 -308 238 -257 417 -231 266 -311 -213 -409 76 183 47 -74 144 148 179 136 445 -291 209 -264 -381 107 -50 -41 162 270 -150 162 -84 342 333 -244 113 82 41 370 -235 -182 -381 440 146 -21 139 45 147 44 221 22 494 -281 -394 -390 -436 -95 -52 -134 264 128 272 433
473 -308 -361 196 -406 25 30 361 -15 -107 171 241 20 -152 -350
HI, Please find my implementation.
Please let me know in case of any issue.
#include <iostream>
#include <fstream>
using namespace std;
int readData(int arr[]){
int count = 0;
// opening file
ifstream inFile("LAB8.DAT");
if(inFile.fail()){
cout<<"Error in opening file"<<endl;
return 1;
}
// reading numbers
int num;
while(inFile>>num){
arr[count] = num;
count++;
}
inFile.close();
return count;
}
int divide(int arr[], int n, int num){
int count = 0;
for(int i=0; i<n; i++){
if(arr[i]%num == 0)
count++;
}
return count;
}
// Driver program to test above functions
int main()
{
// declaring an array of size 300
int arr[300];
int n = readData(arr);
int num;
cout<<"Enter a whole number in range 2-20 ? ";
cin>>num;
int count = divide(arr, n, num);
cout<<count<<" out of "<<n<<" in file were evenly divisible by "<<num<<endl;
return 0;
}
LAB8.DAT IS LISTED BELOW 154 -6 279 215 404 391 -166 199 -302 -469 244 &n
Thank you! /*Lab 8 : Practicing functions and arrays Purpose: */ #include<iostream> #include<fstream> using namespace std; int read_function(int array[], int, int); int main() { int array[300], numba; read_function(array[300]); cout << "Enter a whole number between 2-20: " << endl; cin >> numba; read_function(numba); return 0; } int read_funtion (int arr[300], int num, int Values) { int sum=0; ifstream array_file; array_file.open("Lab8.dat"); for(int i=0; i < 300; i++) { array_file >> arr[i]; cout << arr[i]; sum += i; } cout << sum;...
need help to complete this java program // add appropriate import statements here. // These imports you can leave as is. import javafx.application.Application; import javafx.scene.Group; import javafx.scene.Scene; import javafx.scene.canvas.Canvas; import javafx.scene.canvas.GraphicsContext; import javafx.scene.paint.Color; import javafx.stage.Stage; /** @author yourAccountNameHere */ public class ConnectTheDots extends Application { /* * Do not add code to main(). Add it below in connectTheDots instead. */ public static void main(String[] args) { launch(args); } /*...