I am having problem getting the final result here, it keeps on looping.
#include<stdio.h>
#include<string.h>
#include<conio.h>
#include<math.h>
#include<stdlib.h>
#include<ctype.h>
int main()
{
int i, t, k, max, min, sumof;
printf("Enter number of integer elements in array: ");
scanf("%d",&t);
int a[t];
printf("Enter list of array: \n");
for ( i = 0; i < t ; i++)
{
scanf("%d",&a[i]);
fflush(stdin);
}
// search for secound first and second last number in array
// t-1 = second last and t-2 = secound first#
k=1;
for (i = 0; i < t; i++)
{
if (k==(t-(t-2)))
{
printf("\n The second first number is %d",a[i]);
}
k++;
}
k=1;
for (i = 0; i < t; i++)
{
if (k==(t-1))
{
printf("\nthe second last number is %d",a[i]);
}
k++;
}
//for maximum
max=a[0];
for (i = 0; i < t; i++)
{
if (a[i]> max )
max = a[i];
}
printf("\n maximum is %d \n", max);
//for minimum
min=a[0];
for (i = 0; i < t; i++)
{
if (a[i]< min )
min = a[i];
}
printf(" \n minimum is %d\n ", min);
sumof = 0;
for (i = 0; i < t; i++)
{
sumof = sumof + a[i];
}
printf (" \n sum of array is %d\n ", sumof);
return 0;
}