Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Help Needed Badly and fast! C programming only please. the instructions are belo

ID: 3692293 • Letter: H

Question

Help Needed Badly and fast! C programming only please. the instructions are below:

Move into the tomato directory. Write a program named missing.c that identifies missing numbers. The program takes a maximum value and a data file, as in./a.out 10 mydata In the case above, the file mydata contains numbers in the range of 0 to 9 because the number specified on the command line was 10. If the user specified 500 on the command line, then all numbers in the file would be in the range of 0 to 499. Your program should print all the numbers in this range (0 to max - 1) that were not found in the file. If the user enters./a.out 10 mydata on the command line and the data file mydata contained the numbers below, then your program should print the missing values 0, 4, and 8. 3675356291 The basic logic behind this program is as follows: The user specifies the maximum-value and the name of the file on the command line. Sample executions include./a.out 500 datal and./a.out 1000 myData and./a.out 128 theData. Dynamically allocate space for an array that can hold all the values from 0 to (max-value - 1). Read in all the numbers from the file. You don't know how many numbers are in the file. Use the array to keep track of which numbers you read from the input file. After reading all the data, use the array to figure out which numbers were missing. Your program must allocate the array dynamically and use at least two functions. We recommnd one function to read the file and update your array and a second function to travese the array and print out the numbers that were not seen.

Explanation / Answer

Answer for Question:

This below C program will read the intergers from the file and will store the result in array.

Array will declare the using malloc.

See the below code:

#include <stdio.h>
#define size 10
int getMissingNo (int a[], int n)
{
int i, total;
total = (n+1)*(n+2)/2;
for ( i = 0; i< n; i++)
total -= a[i];
return total;
}
main(int argv[], int argc)
{

FILE *myFile;
myFile = fopen("C:\Users arasimharao\Desktop\data.txt", "r");

//read file into array
int *arr = (int *)malloc(size * sizeof(int));
int i, miss =0;

for (i = 0; i < size; i++)
{
fscanf(myFile, "%1d", &arr[i]);
}

for (i = 0; i < size; i++)
{
printf("Number is: %d ", arr[i]);

}
miss = getMissingNo(arr,5);
printf("%d", miss);
}