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
a construct the"else" part of "if" statement contains anoth "if else" statement is called a) if-else b) else-if-else c) if-else-if-else d) chain if/if-else-if
Declare the structure which contains the following members and write in C list of all students who score more than 75 marks. Roll No, Name, Father Name, Age, City, Marks.
What are near, far and huge pointers?
What is main () in c?
to find the closest pair
what are the different storage classes in c?
Give differences between - new and malloc() , delete and free() ?
What is data types?
Program to find the sum of digits of a given number until the sum becomes a single digit. (e.g. 12345=>1+2+3+4+5=15=>1+5=6)
How can I avoid the abort, retry, fail messages?
What are preprocessor directives in c?
Is c is a middle level language?
Explain what does the function toupper() do?
how to build a exercise findig min number of e heap with list imlemented?
where are auto variables stored? What are the characteristics of an auto variable?