# C Program to Find the Largest of Two Numbers using a Pointer

Write a C program to find the largest of two numbers using a pointer. It allows the user to enter two integer values, and then we assign them to two pointer variables of int type. In this example, we used the else if statement to find the largest of two pointer numbers.

```#include <stdio.h>

int main() {

int x, y, *p1, *p2;

printf("Please Enter Two different values\n");
scanf("%d %d", &x, &y);

p1 = &x;
p2 = &y;

if(*p1 > *p2)
{
printf("The Larges = %d\n", *p1);
}
else if (*p2 > *p1)
{
printf("The Largest = %d\n", *p2);
}
else
{
printf("Both are Equal\n");
}

return 0;
}
```
``````Please Enter Two different values
99
15
The Largest = 99

Please Enter Two different values
12
19
The Largest = 19

Please Enter Two different values
15
15
Both are Equal``````

This c program uses the conditional operator and pointer to find the largest number among the two numbers.

```#include <stdio.h>

int main()
{
int x, y, *p1, *p2, *largest;

p1 = &x;
p2 = &y;

printf("Please Enter Two Different Values\n");
scanf("%d %d", p1, p2);

largest = (*p1 > *p2) ? p1 : p2;
printf("The Largest of Two Number = %d\n", *largest);

return 0;
}
```
{"ft_lang_label":"__label__en","ft_lang_prob":0.60665965,"math_prob":0.99455535,"size":1097,"snap":"2022-40-2023-06","text_gpt3_token_len":339,"char_repetition_ratio":0.13540713,"word_repetition_ratio":0.115,"special_character_ratio":0.35186872,"punctuation_ratio":0.17299578,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9907887,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2022-09-25T07:56:23Z\",\"WARC-Record-ID\":\"<urn:uuid:45807fdd-1b59-4cd9-ad4b-eb7a8ddbe1be>\",\"Content-Length\":\"93403\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:73c36afb-acb4-4edc-b660-bbd9e6e167bd>\",\"WARC-Concurrent-To\":\"<urn:uuid:a8c105db-8819-485f-abed-6c4700e2b526>\",\"WARC-IP-Address\":\"104.26.1.115\",\"WARC-Target-URI\":\"https://www.tutorialgateway.org/c-program-to-find-the-largest-of-two-numbers-using-a-pointer/\",\"WARC-Payload-Digest\":\"sha1:THCBK2OPIW5QRJO4M7O6HUKPU2HSFXMM\",\"WARC-Block-Digest\":\"sha1:DATP7XXNHCIFKHOP6HNEGM5EV67MNNG3\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2022/CC-MAIN-2022-40/CC-MAIN-2022-40_segments_1664030334515.14_warc_CC-MAIN-20220925070216-20220925100216-00037.warc.gz\"}"}