Subscribe

RSS Feed (xml)

Tuesday, January 6, 2009

Write a C program to find both the largest and smallest numbers in a list of integers.

#include(stdio.h) // place this '<' & '>' instead of '(' & ')' before stdio.h
#include(conio.h)
int main(void)
{
int a[50], max, min, i, n;
clrscr( );
printf("Enter how many integers do u want? :");
scanf(" %d", &n);
for( i=0; i< n ; i++)
{
printf("\nEnter the %d number: ", i );
scanf(" %d", &a[ i ]);
if(i==o) { max=a[i ]; min=a[i ]; }
if(a[ i]>max)
max= a[i ];
if(a[i ]< min)
min= a[i ];
}
printf("\n Maximum : %d", max);
printf("\n Minimum : %d", min);
getch( );
return 0;
}

1 comment:

  1. can u please help to solv the foll. problem
    "write a c program using pointers to perform string compartision"

    ReplyDelete