- Get link
- X
- Other Apps
Pointers in C
Every computer has a primary memory.All data and programs need to be placed in the primary memory for execution.The primary or RAM is a collection of memory locations and each location has a specific address.
#include<stdio.h>
https://amzn.to/2yt9n3e
Every computer has a primary memory.All data and programs need to be placed in the primary memory for execution.The primary or RAM is a collection of memory locations and each location has a specific address.
Pointers in C language is a variable that stores/points the address of another variable. A Pointer in C is used to allocate memory dynamically i.e. at run time. The pointer variable might be belonging to any of the data type such as int, float, char, double, short etc.
Example: data_type *ptr_name;
Write a program to find the biggest of three numbers using pointers
#include<stdio.h>
#include<conio.h>
void main()
{
int n1,n2,n3;
int *pn1=&n1; *pn2=&n2;
*pn3=&n3;
printf("\n Enter the first number");
scanf("%d",pn1);
printf("\n Enter the second number");
scanf("%d",pn2);
printf("\n Enter the third number");
scanf("%d",pn3);
if(*pn1>*pn2 && *pn1>pn3)
{
printf("\n % is the largest number",*pn1);
}
if(*pn2>*pn1 && *pn2>*pn3)
{
printf("\n %d is the largest number",*pn2);
}
else
{
printf("\n %d is the largest number",*pn3);
}
getch();
}
Output
Enter the first number:5;
Enter the second number:7;
Enter the third number:3;
7 is the largest number
https://amzn.to/2yt9n3e
Comments
Post a Comment