problem???

#include
#include
int a,b,max;
main()
{
printf("Which is max?
");
printf("a:");scanf("d",&a);
printf("b:");scanf("d",&b);
max=a;
if (max<b)
max=b;
printf("max is :%d",solon);
getch() ;
}
Help me .....soon

Comments

  • : #include
    : #include
    : int a,b,max;
    : main()
    : {
    : printf("Which is max?
    ");
    : printf("a:");scanf("d",&a);
    : printf("b:");scanf("d",&b);
    : max=a;
    : if (max<b)
    : max=b;
    : printf("max is :%d",solon);
    : getch() ;
    : }
    : Help me .....soon
    :
    :

    shouldn't

    printf("a:");scanf("d",&a);
    printf("b:");scanf("d",&b);

    be

    printf("a:");scanf("[b]%[/b]d",&a);
    printf("b:");scanf("[b]%[/b]d",&b);

    "Who is General Failure and why is he reading my hard disk?!"

  • Hi,

    I have modified your code. This should work.

    [code]
    #include
    #include
    #include
    #include

    int main()
    {
    /* Declaring the numbers a and b */
    int a,b;

    printf("Which is max?
    ");

    /* User has to enter the value for a */
    printf("Input the value for a:");
    scanf("%d",&a);

    /* User has to enter the value for b */
    printf("Input the value for b:");
    scanf("%d",&b);

    /* An IF statement to determine the Max value, i.e., a or b */
    if (a < b){
    printf("Max value is %d
    ", b);
    }
    else{
    printf("Max value is %d
    ", a);
    }

    system ("PAUSE");
    return 0;
    }
    [/code]

    Hope this helps,

  • there is no iostream.h in the c++ standard. and what do you need it for anyway? also the redundant "Max value is %d
    " is not nice.

    : Hi,
    :
    : I have modified your code. This should work.
    :
    : [code]
    : #include
    : #include
    : #include
    : #include
    :
    : int main()
    : {
    : /* Declaring the numbers a and b */
    : int a,b;
    :
    : printf("Which is max?
    ");
    :
    : /* User has to enter the value for a */
    : printf("Input the value for a:");
    : scanf("%d",&a);
    :
    : /* User has to enter the value for b */
    : printf("Input the value for b:");
    : scanf("%d",&b);
    :
    : /* An IF statement to determine the Max value, i.e., a or b */
    : if (a < b){
    : printf("Max value is %d
    ", b);
    : }
    : else{
    : printf("Max value is %d
    ", a);
    : }
    :
    : system ("PAUSE");
    : return 0;
    : }
    : [/code]
    :
    : Hope this helps,
    :
    :

  • Yes, you do not need [b]#include [/b] in the code.
  • You could do the following, without the need for [b]#include [/b]:

    [code]
    #include
    #include
    #include

    int main()
    {
    /* Declaring the numbers a and b */
    int a,b;

    printf("Which is max?
    ");

    /* User has to enter the value for a */
    printf("Input the value for a:");
    scanf("%d",&a);

    /* User has to enter the value for b */
    printf("Input the value for b:");
    scanf("%d",&b);

    /* An IF statement to determine the Max value, i.e., a or b */
    if (a < b){
    printf("Max value is %d
    ", b);
    }
    else{
    printf("Max value is %d
    ", a);
    }

    system ("PAUSE");
    return 0;
    }
    [/code]

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories