# Thread: Homework help Array Arguments

1. ## Homework help Array Arguments

I have an assignment to write a program that calculates how many of each character an imput contains and list the characters according to frequency greater to lesser. I thought I might have figured it out by modifying a piece of code from the textbook decribing array arguments, but when I attempted to run the program it aborted. Would someone please tell me what I need to do differently?
Code:
```#include <stdio.h>
#include <stdlib.h>
# define N 52

int find_largest(int a[], int n);
int find_largest(int a[], int n)
{
int i, max;

max = a[1];
for (i = 1; i < n; i++)
if (a[i] > max)
max = a[i];
return max;
}
main()
{
int a[N];
int count = 0;
int i = 0;
int largest;
int *b;
float percent;
char ch;

for (i = 0; i < 53; i++)
a[i] = 0;

printf ("Enter a line of text: ");
ch = getchar();
while (ch != '\n')
{
count++;
if (ch == ' ')
a[0]++;
if (ch >= 'A' && ch <= 'Z')
{
i = ch;
a[i - 64]++;
}
if (ch >= 'a' && ch <= 'z')
a[ch - 70]++;
ch = getchar();
}
printf ("\n\nFREQUENCY TABLE\n---------------\nChar Count %% of Total \n");
printf ("---- ----- ---------- \nALL    %d    100.00%%\n", count);

largest = find_largest(b, N);

for (i = 0; i < 53; i++)
{
if (a[i] != 0)
{
if (i == 0)

ch = ' ';
else if (i >= 1 && i <= 26)
ch = i + 64;
else
ch = i + 70;
percent = (float)(a[i]) / (float)(count) * 100;
printf ("\"%c\"     %d     %.2f%%\n", ch, b, percent);
}
}

system("pause");
return 0;
}```

2. Code:
```    for (i = 0; i < 53; i++)
a[i] = 0;```
array overrun

3. ## Array overrun

I have some other problem than that... It runs fine when I take out
Code:
```int find_largest(int a[], int n);
int find_largest(int a[], int n)
{
int i, max;

max = a[1];
for (i = 1; i < n; i++)
if (a[i] > max)
max = a[i];
return max;
}```
and
Code:
```      int largest;
int *b;
largest = find_largest(b, N);```
then change b to a[i]
It just doesn't list the output according to frequency.

4. Hi,
mistake is.

Code:
```int find_largest(int a[], int n)  \\ You Have Passed (b,N); To it , 'N' is rite But pointer 'b' doesn't have any address to Array. Why??????????
{
int i, max;

max = a[1];
for (i = 1; i < n; i++)     \\ Why You Start The Array From 1 \\
if (a[i] > max)
max = a[i];
return max;
}```
ok