1. Welcome to PHCorner Forums. Take a moment to Sign up and gain unlimited access and extra privileges that guests are not entitled to, such as:

    All that and more! Registration is quick, simple and absolutely free. Join our community today!

C and C++ help for upcoming test

Discussion in 'Coding, Programming' started by glide0227, Jul 19, 2015.

  1. #include<stdio.h>
    #include<conio.h>
    main()
    {
    clrscr();
    int x,n,num,sum=0,L,H=0,odd=0,even=0;
    printf("Enter number of INTEGERS:");
    scanf("%d",&n);
    if(n>0)
    {
    for(x=1;x<=n;x++)
    {
    printf("Enter INTEGER NO #%d:",x);
    scanf("%d",&num);
    sum+=num;
    if(num%2==0)
    even++;
    else
    odd++;
    if(num<L)
    L=num;
    if(num>H)
    H=num;
    }
    printf("\nNUMBER OF INTEGERS INPUTERD:%d\n",n);
    printf("SUM=%d\n",sum);
    printf("LOWEST NUMBER=%d\n",L);
    printf("HIGHEST NUMBER=%d\n",H);
    printf("ODD NUMBERS=%d\n",odd);
    printf("EVEN NUMBERS=%d\n",even);
    }
    else
    {
    printf("Please enter a number more than zero next time!");
    }
    getch();
    return 0;
    }

    nagana nmn sya.. pro kpg nag-input ng negative numbers ndi madetect ang highest..

    salamat s tutulong
     
  2. Causing Glenn

    Causing Glenn daemonX Staff Member Moderator

    _ilan po ang output sa highest?bakit ayaw gumana sa iyo?
     
  3. kung negative numbers input s program 0 ang result.. ang gusto ko mangyari pti highest kht negative mkukuha
     
  4. ang sakit sa mata pag walang indents.
     
  5. Naka initialize kasi ang H mo sa 0. So pag negative ang number di magchange ang value ng H.
    Ang gawin mong initial value ng H at L is ung first na integer. So icheck mo if x == 1, if true,
    iassign mo ang value ng H at L as num. Else icompare mo.
     
    Causing Glenn likes this.