1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126
|
#include <cstdlib>
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#define MSIZE 500
#define DSIZE 500
using namespace std;
int main(int argc, char *argv[])
{
int mul7[MSIZE];
int dig7[DISZE];
int n;
int sr;
int er;
int c7;
int d7;
double mavg;
double davg;
printf("Enter start and end range values: ");
while((n=scanf(" %i %i", &sr, &er))==2)
{
if(sr<0||er>999||sr>er)
printf("range value out of range\n");
else
{
c7=fmul7(sr,er,mul7,MSIZE);
d7=fdig7(sr,er,dig7,DSIZE);
mavg=calcavg(mul7,c7);
davg=calcavg(dig7,d7);
outresults(sr,er,mul7,MISZE,dig7,DSIZE,c7,d7,mavg,davg);
printf("Enter start and end range values:");
}
}
if(n!=EOF)
printf("Input error occurred in scanf\n");
system("PAUSE");
RETURN 0;
}
system("PAUSE");
return EXIT_SUCCESS;
}
}
/************************************************/
int fmul7(int str, int endr, int mul7[], int m7size)
{
int ndx;
int rem;
int i;
i=0;
for(ndx=???;ndx<=????;ndx=ndx+1)
{
rem=ndx%7;
if(rem==?)
{
mul7[?]=???;
i=i+?;
}
}
return ?;
}
/****************************************************/
int fdig7(int str, int endr, int dig7[], int d7size)
{
int ??;
int ???;
int ??;
int ??;
int ??;
int ????;
c7=0;
for(???=str; ???<=endr; ???++)
{
q1=???/100;
rem1=num-(q1*100);
q2=rem1/10;
q3=rem1-(q2*10);
if(q1==?||q2==?||q3==?)
{
dig7[??]=???;
c7++;
}
}
return ??;
}
/**************************************************/
double calcavg(int md7[], int cntmd7)
{
int ndx;
int sum;
double avg;
sum=0;
avg=0.0;
for(ndx=?; ndx<cntmd7;???+++)
sum=sum+md7[???];
if(cntmd7==?)
printf("Average divisor is zero - skip division \n");
else
avg=(double)sum/??????;
return ???;
}
/**********************************************************/
void outresults(int sr, int er, int m7[], int sxm7, int d7[], int szd7, int cm7, int cd7, couble mav, double dav)
{
int i;
printf("Start Range= %i End Range= %i \n", sr, er);
printf"Multiple of 7 count is: %i \n", cm7);
printf("Number having digit 7 count is: %i \n", cd7);
printf("Multiple of 7 values are: \n");
for(i=0; i<cm7;i++)
printf(" %i \n", m7[i]);
printf("Values having digit 7 are: \n");
for(i=0;i<cd7;i++)
printf(" %i \n", d7[i]);
printf("Multiple of 7 average is: %0.21f\n", mav);
printf("Values having digit 7 average is: %0.21f\n", dav)
}
|