Saturday, January 5, 2019

Largest of Three Numbers Using Pointers in C

I am currently accepting programming work, it projects, school and application development.

programming projects, thesis and capstone projects, IT consulting.

work, computer tutorials, and web development work kindly contact me in the following email address for further details.  If you want to advertise on my website kindly contact me also in my email address also. Thank you.
My email address is the following jakerpomperada@gmail.com, jakerpomperada@aol.com, and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.

My telephone number at home here in Bacolod City, Negros Occidental Philippines is  +63 (034) 4335675.

Here in Bacolod I also accepting computer repair, networking and Arduino Project development at a very affordable price.

My personal website is http://www.jakerpomperada.com

Problem 

Write a program that will ask the user to give three numbers
and then the program will check which of the three numbers 
has the highest in terms of numerical value and display the
result on the screen.


Solution

#include<stdio.h>
int main()
{
  int x=0, y=0, z=0;
  int *a, *b, *c;
  
  printf("\n\n");
  printf("\tLargest of Three Numbers");
  printf("\n\n");
  printf("\tEnter Three Numbers : ");
  scanf("%d%d%d",&x, &y, &z);
  a = &x;
  b = &y;
  c = &z;
  if(*a > *b)
  {
    if(*a > *c)
    {
      printf("\n\n");
  printf("\t%d is larger than %d and %d.", *a, *b, *c);
    }
    else
    {
      printf("\n\n");
  printf("\t%d is larger than %d and %d.", *c, *a, *b);
    }
  } 
  else
  {
     if(*b > *c)
     {
        printf("\n\n");
printf("\t%d is larger than %d and %d.", *b, *a, *c);
     }
     else
     {
        printf("\n\n");
printf("\t%d is larger than %d and %d", *c, *a, *b);
     }
  }
printf("\n\n");
printf("\tEnd of Program");
printf("\n\n");


No comments:

Post a Comment