שפת C
Question:

בעזרת לולאה כתוב תוכנית שתקלוט 30 מספרים שלמים , ותדפיס את המספר הגדול ביותר ואת המספר הקטן ביותר 

0 People tried to answer this question



Comments:
1.  Assadi Ameer (21.11.2016 pm 08.23.55)
Answer

#include <stdio.h>
#include<conio.h>

void main()
{   

    /**
    Author: Ameer M. Assadi
    email: AmeerAssadime@gmail.com
    **/

    const size_t N = 30;

    int value;  
    int smallest, largest;

    printf ( " Enter %d integers.", N );
    printf ( " And I will give you the smallest and the largest. " );

    size_t i = 0;

    while ( i < N && scanf( "%d", &value ) == 1 )
    {
        if ( i++ == 0 )
        {
            smallest = largest = value;
        }
        else
        {
            if ( value < smallest )
            {
                smallest = value;
            }
            else if ( largest < value )
            {
                largest = value;
            }
        }
    }

    if ( i != 0 )
    {
        printf( " Among %d entered values the smallest is %d and the largest is %d ",i, smallest, largest );
    }

    _getch();
}



History of edits
Edited BY: yara daghash Edit Date: 2016-11-23 20:09:29
Created By: yara daghash Edit Date: 2016-11-21 11:06:03
More Interactive Questions that might interest you In Computer