Problem 21: Maximum

Take 3 integers from user using scanf() function and write a program to find the maximum one.

 

2,490 total views, 2 views today

Comments

comments

2 thoughts on “Problem 21: Maximum”

  1. #include
    int main()
    {
    int A[3];
    int i;
    for(i=0;i<3;i++)
    scanf("%d",&A[i]);
    int max;
    max=A[0];
    for(i=0;i<3;i++){
    if(max<=A[i])
    max=A[i];
    }
    printf("%d\n",max);
    return 0;
    }

  2. #include
    int main()
    {
    int a,b,c;
    printf(“Enter three number\n”);
    scanf(“%d%d%d”,&a,&b,&c);
    if((a>=c)&&(a>=b)){
    printf(“The maximum number is %d\n”,a);
    }
    else if((b>=c)&&(b>=a)){
    printf(“The maximum number is %d\n”,b);
    }
    else{
    printf(“The maximum number is %d\n”,c);
    }
    }

Leave a Reply

Your email address will not be published.