#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
int main() {
int tempnum = 0;
int i;
int mainnum ;
int maincount = 0;
int tempcount ;
int *a;
int n;
FILE * file;
file = fopen ("input.txt", "r");
if(file==NULL) {
printf("Error: can't open file.\n");
return 1;
}
else {
printf("File opened successfully. Contents:\n\n");
while(feof(file)== 0) {
for ( i=0; i<n ; i++)
fscanf(file, "%s", &a[i]);
}
fclose(file);
for ( i=0; i<n-1 ; i++) {
if ( a[i] == tempnum){
tempcount = tempcount + 1;}
else{
tempnum = a[i];
tempcount = 1;
}
if (tempcount > maincount) {
maincount = tempcount;
mainnum = tempnum;
}}
printf(" %s" ,mainnum );
printf(" %s ", maincount);
getch ();
return 0;
}}
example
input.txt 5 3 7 7 7 7 4 3 3 9 9 9 9 9 9 9 8 9 0
0 indicates the end of data, and number range from 1 to 9.program should read numbers from input.txt and output should be number appear the most one after the other and number of times eg for the above 9 7.