#include <stdio.h>
#include <stdlib.h>

int main ()
{
  int i,n,big;
  int * pData;
  printf ("Amount of numbers to be entered: ");
  scanf ("%d",&i);
  pData = (int*) calloc (i,sizeof(int));
  if (pData==NULL) exit (1);

  for (n=0;n<i;n++)
  {
      printf ("Enter number #%d: ",n);

    scanf ("%d",&pData[n]);
  }
 big=pdata[0];
 for(n=0;n<i;n++)
 {
     if(big>pdata[n])
     {
         big=pdata[n];
     }
     printf("%d",big);

}
}

what is the error??

if(big>pdata[n])

Are you saying here:
if "big" is greater than the number in the array, then replace it?


[After that]
Are you going to free the data allocated on line 10?

#include <stdio.h>
#include <stdlib.h>

int main ()
{
  int i,n,big;
  int * pData;
  printf ("Amount of numbers to be entered: ");
  scanf ("%d",&i);
  pData = (int*) calloc (i,sizeof(int));
  if (pData==NULL) exit (1);

  for (n=0;n<i;n++)
  {
      printf ("Enter number #%d: ",n);

    scanf ("%d",&pData[n]);
  }
 big=pdata[0];
 for(n=0;n<i;n++)
 {
     if(pdata[n]>big)
     {
         big=pdata[n];
     }
     printf("%d",big);

}
free(pdata);
return 0;
}

but this is also showing error

but this is also showing error

The code has syntax errors. C is case sensitive, but you use both pData and pdata to mean the same thing. Try this instead:

#include <stdio.h>
#include <stdlib.h>

int main ()
{
    int i,n,big;
    int * pdata;
    printf ("Amount of numbers to be entered: ");
    scanf ("%d",&i);
    pdata = (int*) calloc (i,sizeof(int));
    if (pdata==NULL) exit (1);

    for (n=0; n<i; n++)
    {
        printf ("Enter number #%d: ",n);
        scanf ("%d",&pdata[n]);
    }
    big=pdata[0];
    for(n=0; n<i; n++)
    {
        if(pdata[n]>big)
        {
            big=pdata[n];
        }
        printf("%d",big);

    }
    free(pdata);
    return 0;
}

But your algorithm is excessively complicated. There's no need to store the numbers since you only need to retain the biggest one found so far:

#include <stdio.h>

int main(void)
{
    int num;
    
    printf("Enter a series of numbers (EOF to stop): ");
    
    // Get the first number separately to simplify the logic
    if (scanf("%d", &num) == 1)
    {
        int largest = num;
        
        // Now get the rest of the numbers and find the largest
        while (scanf("%d", &num) == 1)
        {
            if (num > largest)
            {
                largest = num;
            }
        }
        
        printf("The largest was %d\n", largest);
    }
    else
    {
        printf("No numbers were entered.\n");
    }
    
    return 0;
}

OK. You could have just changed the > to a <, but that's OK.

Where does it show or give an error?

it shows 3 erros like this 1.pdata undeclared(first use in this function)
2.each undeclared identifier is reported only onc
3.for each function it appears

it shows error in 18th line

is c case sensitive???i thought java was only case sensitive

Nope, Java didn't corner the market on case sensitivity. A lot of languages that aren't Java are case sensitive, most of them, in fact. :D

This article has been dead for over six months. Start a new discussion instead.