Lavanya Lavanya - 1 month ago 18
C Question

Debug the error

I have created a code to find the

largest number
.
I have an error in main function. It says syntax error before t.

Please correct my code.

#include<stdio.h>
#include<conio.h>
int main()
{
int a[100],n,i,t;
printf("enter the array size");
scanf("%d",&n);
printf("enter the array elements");
for(i=0;i<n;i++)
{ scanf("%d",&a[i]);
}
t=0;
for(i=0;i<n;i++)
{


if (a[i]t){
t=a[i];



}
}
printf("the maximum number is %d",t);
getch();
return 0;
}

Answer

Syntax error is at following line

if (a[i]t){

Use

if (a[i]>t)