1 Attachment(s)
Print the 2 greater numbers of 10 numbers.
Code:
/*C Program must enter 10 numbers and print the 2 greatest ones using only while and if.
i.e.
1 2 3 4 5 6 7 8 9 10
greatest numbers are: 10 and 9.
This is what I've done so far:
*/
#include <stdio.h>
#include <conio.h>
main()
{
int num, greater, greater2, counter;
counter = 0;
printf("\Enter number and I will tell you which\n");
printf("ones are the two largest numbers of ten: ");
scanf("%d", &num);
greater = num;
counter ++;
while (counter < 10){
printf("\nEnter number and I will tell you which\n");
printf("ones are the two largest numbers of ten: ");
scanf("%d", &num);
if (num > greater) {
greater2 = num;
greater = greater;
}
else{
greater2 = greater;
}
{
counter ++;
}
}
printf("\n\nThe two largest numbers are: %d and %d\n", greater2, greater);
getch();
return 0;
}
/* Any help????? */