Link to home
Start Free TrialLog in
Avatar of DexTexMex
DexTexMexFlag for United Kingdom of Great Britain and Northern Ireland

asked on

C programming

Hi i'm new to C programming and need some help with writing a program.

Im trying to write a program that will read 3 numbers from the keyboard and print the largest one on the screen.

I have to only use 2 variables, 1 to read the numbers and one to hold the highest value.

I would be most grateful for any help

ASKER CERTIFIED SOLUTION
Avatar of Christopher Kile
Christopher Kile
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of seanyp_2007
seanyp_2007

Here is a possible solution

#include <stdio.h>
#include <conio.h>

void main(){
      int Num=0, nVal;

      printf("Enter three numbers followed by return. 0 to END\n");
      do{
            scanf("%d",&nVal);
            if(nVal > Num)
            {
                  Num = nVal;
            }
      }while(nVal != 0 );
      printf("The largest number is : %d",Num);
      getche();
}