Menu Close

C语言发现三个数的最大数

#include<stdio.h>
int main()
{
   int num1,num2,num3;

   //Ask user to input any three integer numbers
   printf("\nEnter value of num1, num2 and num3:");
   //Store input values in variables for comparsion
   scanf("%d %d %d",&num1,&num2,&num3);

   if((num1>num2)&&(num1>num3))
   printf("\n Number1 is greatest");
   else if((num2>num3)&&(num2>num1))
   printf("\n Number2 is greatest");
   else
   printf("\n Number3 is greatest");
   return 0;
}

对三个数仙相互比较,给出最大数。
结果

Enter value of num1, num2 and num3:789 345 1234

Number3 is greatest

 

READ  C语言练习:打印出26个英文字母
除教程外,本网站大部分文章来自互联网,如果有内容冒犯到你,请联系我们删除!

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

Leave the field below empty!

Posted in C语言习题集