helllo sir ,
what is the main use of the pointer ,array ,and the
structure with the example of a programe

Answer Posted / fazlur rahaman naik

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];
};







Is This Answer Correct ?    3 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the use of extern in c?

651


In c programming typeing to occupy the variables in memory space. if not useing the variable the memory space is wasted.ok, how to avoid the situation..? (the variable is used & notused)

1635


What is a lookup table in c?

629


Why is c known as a mother language?

751


what is use of malloc and calloc?

1388






What are the 4 types of unions?

614


Define recursion in c.

704


What is your stream meaning?

610


What are the rules for identifiers in c?

592


Why c language is called c?

573


Why should I prototype a function?

644


How can I write functions that take a variable number of arguments?

631


What are the different types of errors?

648


What is %lu in c?

690


At a shop of marbles, packs of marbles are prepared. Packets are named A, B, C, D, E …….. All packets are kept in a VERTICAL SHELF in random order. Any numbers of packets with these names could be kept in that shelf as in this example: bottom of shelf ---> [AAAJKRDFDEWAAYFYYKK]-----Top of shelf. All these packets are to be loaded on cars. The cars are lined in order, so that the packet could be loaded on them. The cars are also named [A, B, C, D, E,………….]. Each Car will load the packet with the same alphabet. So, for example, car ‘A’ will load all the packets with name ‘A’. Each particular car will come at the loading point only once. The cars will come at the loading point in alphabetical order. So, car ‘B’ will come and take all the packets with name ‘B’ from the shelf, then car ‘C’ will come. No matter how deep in the shelf any packet ‘B’ is, all of the ‘B’ packets will be displaced before the ‘C’ car arrives. For that purpose, some additional shelves are provided. The packets which are after the packet B, are kept in those shelves. Any one of these shelves contains only packets, having the same name. For example, if any particular shelf is used and if a packet with name X is in it, then only the packets having names X will be kept in it. That shelf will look like [XXXXXXX]. If any shelf is used once, then it could be used again only if it is vacant. Packets from the initial shelf could be unloaded from top only. Write a program that finds the minimum total number of shelves, including the initial one required for this loading process.

1736