UrbanPro
true

Take BCA Tuition from the Best Tutors

  • Affordable fees
  • 1-1 or Group class
  • Flexible Timings
  • Verified Tutors

Search in

Pointers Concept

Sudarshan Gupta
07/06/2017 0 0

Every variable has a memory location and every memory location has its address defined which can be accessed using ampersand (&) operator, which denotes an address in memory. Consider the following example, which prints the address of the variables defined:

int main () {   int  var1;   char var2[10];   printf("Address of var1 variable: %x\n", &var1  );   printf("Address of var2 variable: %x\n", &var2  );   return 0;}

Output:
Address of var1 variable: bff5a400Address of var2 variable: bff5a3f6

A pointer is a variable whose value is the address of another variable, i.e, direct address of the memory location. Like any variable or constant, you must declare a pointer before using it to store any variable address. The general form of a pointer variable declaration is:

type *var-name;

Here, type is the pointer's base type, it must be a valid C data type and var-name is the name of the pointer variable. The asterisk * used to declare a pointer is the same asterisk used for multiplication. However, in this statement the asterisk is being used to designate a variable as a pointer. Take a look at some of the valid pointer declarations:

int    *ip;    /* pointer to an integer */double *dp;    /* pointer to a double */float  *fp;    /* pointer to a float */char   *ch     /* pointer to a character */

#include int main () {   int  var = 20;   /* actual variable declaration */   int  *ip;        /* pointer variable declaration */   ip = &var;  /* store address of var in pointer variable*/   printf("Address of var variable: %x\n", &var  );   /* address stored in pointer variable */   printf("Address stored in ip variable: %x\n", ip );   /* access the value using the pointer */   printf("Value of *ip variable: %d\n", *ip );   return 0;}

Output:
Address of var variable:bffd8b3cAddress stored in ip variable:bffd8b3cValue of *ip variable:20
0 Dislike
Follow 0

Please Enter a comment

Submit

Other Lessons for You

Maths Home Tutor In Kolkata
Study text book properly and give test regularly.

C Program to print Block Letter and Small Case Alphabets using C
/* WAP to print Block Letter and Small Case Alpahbets using C*/ //Hint:use ascii code(value) to print #include#include void main(){ int i; clrscr(); //Block Letters Alphabets printf("Block Letters Alphabets\n");...

The ABCs Of Success For A Software Developer
“There is more to know for career advancement rather than focusing on codes and its challenges to become a successful developer”. A developer is the one who creates software application by...

How To Setup development Environment Of Java?
After installation of JAVA, we need to setup 2 environment variables. First one is JAVA_HOME and second is Path. Below steps to set up Java environment to compile & execute Java programs from command...

How To Pass CCC Exam? What Is CCC Examination?
NIELIT-CCC Examination Tips and Details Introduction: This course is designed by NIELIT, Delhi to aim at imparting a basic level IT Literacy programme for the common man. This programme has essentially...
X

Looking for BCA Tuition Classes?

The best tutors for BCA Tuition Classes are on UrbanPro

  • Select the best Tutor
  • Book & Attend a Free Demo
  • Pay and start Learning

Take BCA Tuition with the Best Tutors

The best Tutors for BCA Tuition Classes are on UrbanPro

This website uses cookies

We use cookies to improve user experience. Choose what cookies you allow us to use. You can read more about our Cookie Policy in our Privacy Policy

Accept All
Decline All

UrbanPro.com is India's largest network of most trusted tutors and institutes. Over 55 lakh students rely on UrbanPro.com, to fulfill their learning requirements across 1,000+ categories. Using UrbanPro.com, parents, and students can compare multiple Tutors and Institutes and choose the one that best suits their requirements. More than 7.5 lakh verified Tutors and Institutes are helping millions of students every day and growing their tutoring business on UrbanPro.com. Whether you are looking for a tutor to learn mathematics, a German language trainer to brush up your German language skills or an institute to upgrade your IT skills, we have got the best selection of Tutors and Training Institutes for you. Read more