Program to find the largest integer element of an array.

Joined
Mar 2, 2022
Messages
1
Reaction score
0
#include<stdio.h>
int main()
{
int t;
scanf("%d",&t);
while(t--)
{
int n;
scanf("%d",&n);
int arr[n],hell[n],count;
for (int i=0;i<n;++i)
{
scanf("%d",&arr);
}
for(int i=0;i<n;++i)
{

if (i=n-1)
{
break;
}
else if (arr>arr[i+1])
{
count=arr;

}
else if(arr<arr[i+1])
{
count=arr[i+1];

}

}
printf("%d",&count);
}
}

/*I wanted to find the largest element in an int array, which has 'n' elements.
first user will input no. of testcases.
then input the no. of element
then input the elements
program should then print the largest integer element(Only integers will be entered by user)
on execution I am getting some garbage value
for eg. test cases=1,no. of elements=2,elemts=77,101,then program prints garbage like -1485932559*/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,818
Messages
2,569,727
Members
45,661
Latest member
NadineBour

Latest Threads

Top