ALLInterview.com :: Home Page KalAajKal.com
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
info       Did you received any Funny E-Mails from your Friends and like to share with rest of our friends? Yeah!! you can post that stuff   HERE
Google
 
Categories >> Software >> Programming-Languages >> C
 
 
 
Question
helllo sir ,
 what is the main use of the pointer ,array ,and the 
structure with the example of a programe
 Question Submitted By :: Pawan Kumar Singh
I also faced this Question!!     Rank Answer Posted By  
 
Answer
With the help of pointer we can access a variable 
address.with that we can change the value of the 
variable.for eg: 

main()
{
 int a = 10;
 int *x;
 
 x = &a;
 
 printf("a = %d\n",a);
 *x = 978;
 printf("a = %d\n");
}

now the value of the a is 978.

if we pass a pointer to a variable to a function then the 
value of that variable will be chageed if we change it in 
that function.
for eg: 

main()
{
  int b = 87;
  int *x;
  x = &b;
  fun(x);
  printf("b = %d\n");
}

fun(int *x)
{
  *x = 879;
}

here the value of the b will be 879.

Array : Array is a collection of variable of similar types. 
i.e. it can b an collection of n number of integers or arry 
of characters etc.
for eg:

 Take a examination marks of a class.it could b a float 
value or a integer value.Then u need to take five variables 
of float type or interger type.Insted of that u can take an 
array of float or integer type.

  float marks[n];

arrays r mainly used for strings.

     char string[n];

Structure:
The structure is a collection of variables of  various data 
types.

the best example for this is employee details or student 
details.

   struct emloyee
   {
     char name[25];
     int age;
     float salary;
     char mobile[15];
     char desig[25];
   };






   
 
0
Fazlur Rahaman Naik
 
View All Answers
 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us interview questions urls   External Links 
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com