Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR C

This C Program is used to find the greatest among ten numbers.

#include <stdio.h>
  int main() {
    int a[10];
    int i;
    int greatest;
    printf("Enter ten values:");
    //Store 10 numbers in an array
    for (i = 0; i < 10; i++) {
        scanf("%d", &a[i]);
    }
    //Assume that a[0] is greatest
    greatest = a[0];
    for (i = 0; i < 10; i++) {
        if (a[i] > greatest) {
        greatest = a[i];
    }
    }
    printf("
    Greatest of ten numbers is %d", greatest);
    return 0;
  }
Source by www.w3schools.in #
 
PREVIOUS NEXT
Tagged: #This #C #Program #find #greatest #ten
ADD COMMENT
Topic
Name
7+3 =