Wednesday

Write a program to store ten different constant variables in an array and print out the greatest number.

#include<stdio.h>
#include<conio.h>
void main()
  {
    int i,num[10],g;
    clrscr();
    printf("\nEnter 10 numbers");
    for(i=0;i<10;i++)
     scanf("%d",&num[i]);
    g=num[0];
    for(i=1;i<10;i++)
     {
      if (num[i]>g)
       g=num[i];
     }
    printf("\nThe greatest number is %d",g);
    getch();
}

No comments:

Post a Comment

Rahul-Notes