Code:
#include <iostream>
#include <iomanip>
#include <fstream>
#include <string>
#include <vector>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <set>
using namespace std;
int main()
{
char z;
float characters=0, dig, di=0, ca=0, cb=0, cc=0, cd=0, ce=0, cf=0, cg=0, ch=0, ci=0, cj=0, ck=0, cl=0, cm=0, cn=0, co=0, cp=0, cq=0, cr=0, cs=0, ct=0, cu=0, cv=0, cw=0, cx=0, cy=0, cz=0;
float a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, zz;
ifstream inData;
FILE *file1;
file1 = fopen("text1.dat", "r");
//counts specific characters and digits
while(!feof(file1))
{
fscanf(file1,"%c",&z);
characters++;
if(z=='A' || z=='a')
{ca++;
a=ca;}
else if(z=='B' || z=='b')
{cb++;
b=cb;}
else if(z=='C' || z=='c')
{cc++;
c=cc;}
else if(z=='D' || z=='d')
{cd++;
d=cd;}
else if(z=='E' || z=='e')
{ce++;
e=ce;}
else if(z=='F' || z=='f')
{cf++;
f=cf;}
else if(z=='G' || z=='g')
{cg++;
g=cg;}
else if(z=='H' || z=='h')
{ch++;
h=ch;}
else if(z=='I' || z=='i')
{ci++;
i=ci;}
else if(z=='J' || z=='j')
{cj++;
j=cj;}
else if(z=='K' || z=='k')
{ck++;
k=ck;}
else if(z=='L' || z=='l')
{cl++;
l=cl;}
else if(z=='M' || z=='m')
{cm++;
m=cm;}
else if(z=='N' || z=='n')
{cn++;
n=cn;}
else if(z=='O' || z=='o')
{co++;
o=co;}
else if(z=='P' || z=='p')
{cp++;
p=co;}
else if(z=='Q' || z=='q')
{cq++;
q=cq;}
else if(z=='R' || z=='r')
{cr++;
r=cr;}
else if(z=='S' || z=='s')
{cs++;
s=cs;}
else if(z=='T' || z=='t')
{ct++;
t=ct;}
else if(z=='U' || z=='u')
{cu++;
u=cu;}
else if(z=='V' || z=='v')
{cv++;
v=cv;}
else if(z=='W' || z=='w')
{cw++;
w=cw;}
else if(z=='X' || z=='x')
{cx++;
x=cx;}
else if(z=='Y' || z=='y')
{cy++;
y=cy;}
else if(z=='Z' || z=='z')
{cz++;
zz=cz;}
else if(z=='0' || z=='1' || z=='2' || z=='3' || z=='4' || z=='5' || z=='6' || z=='7' || z=='8' || z=='9')
{di++;
dig=di;}
}
//checking logic
characters--;
cout << "The letter A occurs " << ca << " times and the ratio to non white space is " << setprecision(3) << (ca/characters) << endl;
cout << "The letter B occurs " << cb << " times and the ratio to non white space is " << setprecision(3) << (cb/characters) << endl;
cout << "The letter C occurs " << cc << " times and the ratio to non white space is " << setprecision(3) << (cc/characters) << endl;
cout << "The letter D occurs " << cd << " times and the ratio to non white space is " << setprecision(3) << (cd/characters) << endl;
cout << "The letter E occurs " << ce << " times and the ratio to non white space is " << setprecision(3) << (ce/characters) << endl;
cout << "The letter F occurs " << cf << " times and the ratio to non white space is " << setprecision(3) << (cf/characters) << endl;
cout << "The letter G occurs " << cg << " times and the ratio to non white space is " << setprecision(3) << (cg/characters) << endl;
cout << "The letter H occurs " << ch << " times and the ratio to non white space is " << setprecision(3) << (ch/characters) << endl;
cout << "The letter I occurs " << ci << " times and the ratio to non white space is " << setprecision(3) << (ci/characters) << endl;
cout << "The letter J occurs " << cj << " times and the ratio to non white space is " << setprecision(3) << (cj/characters) << endl;
cout << "The letter K occurs " << ck << " times and the ratio to non white space is " << setprecision(3) << (ck/characters) << endl;
cout << "The letter L occurs " << cl << " times and the ratio to non white space is " << setprecision(3) << (cl/characters) << endl;
cout << "The letter M occurs " << cm << " times and the ratio to non white space is " << setprecision(3) << (cm/characters) << endl;
cout << "The letter N occurs " << cn << " times and the ratio to non white space is " << setprecision(3) << (cn/characters) << endl;
cout << "The letter O occurs " << co << " times and the ratio to non white space is " << setprecision(3) << (co/characters) << endl;
cout << "The letter P occurs " << cp << " times and the ratio to non white space is " << setprecision(3) << (cp/characters) << endl;
cout << "The letter Q occurs " << cq << " times and the ratio to non white space is " << setprecision(3) << (cq/characters) << endl;
cout << "The letter R occurs " << cr << " times and the ratio to non white space is " << setprecision(3) << (cr/characters) << endl;
cout << "The letter S occurs " << cs << " times and the ratio to non white space is " << setprecision(3) << (cs/characters) << endl;
cout << "The letter T occurs " << ct << " times and the ratio to non white space is " << setprecision(3) << (ct/characters) << endl;
cout << "The letter U occurs " << cu << " times and the ratio to non white space is " << setprecision(3) << (cu/characters) << endl;
cout << "The letter V occurs " << cv << " times and the ratio to non white space is " << setprecision(3) << (cv/characters) << endl;
cout << "The letter W occurs " << cw << " times and the ratio to non white space is " << setprecision(3) << (cw/characters) << endl;
cout << "The letter X occurs " << cx << " times and the ratio to non white space is " << setprecision(3) << (cx/characters) << endl;
cout << "The letter Y occurs " << cy << " times and the ratio to non white space is " << setprecision(3) << (cy/characters) << endl;
cout << "The letter Z occurs " << cz << " times and the ratio to non white space is " << setprecision(3) << (cz/characters) << endl;
cout << "The digits 0-9 occur " << di << " times and the ratio to non white space is " << setprecision(3) << (di/characters) << endl;
//************Below this line is the problem area!*****************
// sort & median
int size;
float array[27]={a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, zz};
int middle = size/2;
float median;
if (size%2==0)
{median = static_cast<float>(array[middle-1]+array[middle])/2;}
else median = static_cast<float>(array[middle]);
cout << "The median of the array is:" << median << endl;
}