JOIN us on
WhatsApp Group Join Now
Telegram Join Join Now

हिंदी माध्यम नोट्स

Class 6

Hindi social science science maths English

Class 7

Hindi social science science maths English

Class 8

Hindi social science science maths English

Class 9

Hindi social science science Maths English

Class 10

Hindi Social science science Maths English

Class 11

Hindi sociology physics physical education maths english economics geography History

chemistry business studies biology accountancy political science

Class 12

Hindi physics physical education maths english economics

chemistry business studies biology accountancy Political science History sociology

Home science Geography

English medium Notes

Class 6

Hindi social science science maths English

Class 7

Hindi social science science maths English

Class 8

Hindi social science science maths English

Class 9

Hindi social science science Maths English

Class 10

Hindi Social science science Maths English

Class 11

Hindi physics physical education maths entrepreneurship english economics

chemistry business studies biology accountancy

Class 12

Hindi physics physical education maths entrepreneurship english economics

chemistry business studies biology accountancy

Categories: C Language in hindi

pointer examples in c language in hindi , pointer example in computer programming c पॉइंटर उदाहरण

pointer example in computer programming c पॉइंटर उदाहरण , some pointer examples in c language in hindi :

Pointer एक variable है जो किसी दुसरे variable के address को hold करता है | Pointer variable एक valid memory address को contain करता है |

Pointer के benefits

1.Pointer variable से array और structure को efficiently handle कर सकते है |

2.Pointer variable का use , किसी function से multiple values को return करने के लिए किया जाता है |

3.Pointer variable का use , dynamic memory allocation के लिए किया जाता है |

4.Pointer variable का function मे argument pass करने के लिए किया जाता है |

किसी प्रोग्रामर के लिए pointer के concept को समजना मुश्किल होता है इसलिए इस article मे pointer के based पर कुछ advance उदहारण को discuss करेगे |

Example 1

write a program to sorting operation (Ascending order) in array using pointer.

इस उदहारण मे , pointer से किसी array मे sorting operation के प्रोग्राम को discuss करगे |

Explanation

सबसे पहले header field मे , चार यूजर define functions को declare करेगे |

main function:

1.यूजर से array की size और elements को input करा लेते है |उसके बाद scanarray() function को call करते है जिसमे declare array name और size pass होती है |

2.उसके बाद sort() function को call किया जाता है , जिसमे declare array name , size , compare function [ascend()] pass होती है |

3.फिर print () function से array के element को printकरा देते है |

scanarray() मे ,

इस function से , pointer से array मे यूजर द्वारा input की गयी values को assign किया जाता है |

1.सबसे पहले pointer variable end को set किया जता है |

2.जब तक pointer variable ‘a’ की value end से छोटी या equal होती है तब तक array मे value assign होती है |

ascend() मे ,

इस function मे array के दो elements मे compare किया जाता है |अगर swapping compare function ascend() की value पर निर्भर करता है |

अगर इस function से ‘0’ से ज्यादा value आती है तब swapping function होता है |

print() मे

इस function से , array के elements को print किया जाता है |

1.सबसे पहले pointer variable end को set किया जता है |

2.जब तक pointer variable ‘a’ की value end से छोटी या equal होती है तब तक array मे value print होती है |

sort() मे ,

इस function array को sort operation का code होता है |इसमें दो pointer variables current और check होते है|

1.सबसे पहले end को set किया जाता है |

2.loop चलाया जाता है loop तब तक चलता है जब pointer variable current की value end से छोटी होती है |

3.इस loop की body मे ,pointer variable को current से initial करते है | उसके बाद एक और loop चलाया जाता है |

4.इस loop की body मे compare function को call किया जाता है जिसमे current और check को pass किया जाता है |

5.अगर compare function की value ‘0’ से ज्यादा होती तो swapping operation perform होता है |

6.current और check को increment कर देते है |

source code :

#include

#include

void scanarray(int *a,int size);

void print(int *a, int size);

int ascend (int *num1,int *num2);

int sort (int *a,int size,int(*compare)(int * ,int *));

void main()

{

int array[size],size;

printf (“Enter Size”);

scanf(“%d”,&size);

printf(“Enter Elements”);

scanarray(array , size);

printf(“Before Sorting”);

print(array , size);

printf(“After sorting”);

sort (array,size,ascend);

print(array,size);

getch();

}

void scanarray(int *a,int size)

{

int *end = (a+size-1);

while(a<=end)

{

scnaf(“%d”,a++);

}

}

void print(int *a, int size)

{

int *end = (a+size-1);

while(a<=end)

{

printf(“%d”,*(a++));

}

}

int ascend (int *num1,int *num2)

{

return (*num1)-(*num2);

}

void sort (int *a,int size,int(*compare)(int * ,int *))

{

int *end = (a+size-1);

int *current=a;

int *check;

while(current <= end)

{

check= current;

while(check <= end ) { if(compare (current, check )>0)

{

*current ^= *check;

*check ^= *current;

*current ^= *check;

}

check++;

}

current++;

}

}

Example 2

write a program to sorting operation (descending order) in array using pointer.

इस उदहारण मे , pointer से किसी array मे sorting operation के प्रोग्राम को discuss करगे |

Explanation

सबसे पहले header field मे , चार यूजर define functions को declare करेगे |

main function:

1.यूजर से array की size और elements को input करा लेते है |उसके बाद scanarray() function को call करते है जिसमे declare array name और size pass होती है |

2.उसके बाद sort() function को call किया जाता है , जिसमे declare array name , size , compare function [descend()] pass होती है |

3.फिर print () function से array के element को printकरा देते है |

scanarray() मे ,

इस function से , pointer से array मे यूजर द्वारा input की गयी values को assign किया जाता है |

1.सबसे पहले pointer variable end को set किया जता है |

2.जब तक pointer variable ‘a’ की value end से छोटी या equal होती है तब तक array मे value assign होती है |

descend() मे ,

इस function मे array के दो elements मे compare किया जाता है |अगर swapping compare function ascend() की value पर निर्भर करता है |

अगर इस function से ‘0’ से ज्यादा value आती है तब swapping function होता है |

print() मे

इस function से , array के elements को print किया जाता है |

1.सबसे पहले pointer variable end को set किया जता है |

2.जब तक pointer variable ‘a’ की value end से छोटी या equal होती है तब तक array मे value print होती है |

sort() मे ,

इस function array को sort operation का code होता है |इसमें दो pointer variables current और check होते है|

1.सबसे पहले end को set किया जाता है |

2.loop चलाया जाता है loop तब तक चलता है जब pointer variable current की value end से छोटी होती है |

3.इस loop की body मे ,pointer variable को current से initial करते है | उसके बाद एक और loop चलाया जाता है |

4.इस loop की body मे compare function को call किया जाता है जिसमे current और check को pass किया जाता है |

5.अगर compare function की value ‘0’ से ज्यादा होती तो swapping operation perform होता है |

6.current और check को increment कर देते है |

source code :

#include

#include

void scanarray(int *a,int size);

void print(int *a, int size);

int descend (int *num1,int *num2);

int sort (int *a,int size,int(*compare)(int * ,int *));

void main()

{

int array[size],size;

printf (“Enter Size”);

scanf(“%d”,&size);

printf(“Enter Elements”);

scanarray(array , size);

printf(“Before Sorting”);

print(array , size);

printf(“After sorting”);

sort (array,size,descend);

print(array,size);

getch();

}

void scanarray(int *a,int size)

{

int *end = (a+size-1);

while(a<=end)

{

scnaf(“%d”,a++);

}

}

void print(int *a, int size)

{

int *end = (a+size-1);

while(a<=end)

{

printf(“%d”,*(a++));

}

}

int descend (int *num1,int *num2)

{

return (*num2)-(*num1);

}

void sort (int *a,int size,int(*compare)(int * ,int *))

{

int *end = (a+size-1);

int *current=a;

int *check;

while(current <= end)

{

check= current;

while(check <= end ) { if(compare (current, check )>0)

{

*current ^= *check;

*check ^= *current;

*current ^= *check;

}

check++;

}

current++;

}

}

Example 3

write a program to reverse operation in array using pointer.

इस उदहारण मे , pointer से किसी array मे reverse operation के प्रोग्राम को discuss करगे |

Explanation

सबसे पहले header field मे , दो user define functions को declare करेगे |

main function:

1.यूजर से array की size और elements को input करा लेते है |उसके बाद scanarray() function को call करते है जिसमे declare array name और size pass होती है |

2.इस प्रोग्राम मे दो pointer variables को use किया जाता है |जिसमे एक pointer variable left, left side के element के address को hold करता है और pointer variable right , right side के element के address को hold करता है |

5. loop चलाया जाता है :ये loop तब तक चलता है जब तक left और right की value छोटी होती है |

6.loop इस body मे , left और right variable की value को interchange किया जाता है |

3.फिर print () function से array के element को printकरा देते है |

scanarray() मे ,

इस function से , pointer से array मे यूजर द्वारा input की गयी values को assign किया जाता है |

1.सबसे पहले pointer variable end को set किया जता है |

2.जब तक pointer variable ‘a’ की value end से छोटी या equal होती है तब तक array मे value assign होती है |

print() मे

इस function से , array के elements को print किया जाता है |

1.सबसे पहले pointer variable end को set किया जता है |

2.जब तक pointer variable ‘a’ की value end से छोटी या equal होती है तब तक array मे value print होती है |

source code :

#include

#include

void scanarray(int *a,int size);

void print(int *a, int size);

void main()

{

int *left ,*right ;

int *temp;

int array[size],size;

printf (“Enter Size”);

scanf(“%d”,&size);

printf(“Enter Elements”);

scanarray(array , size);

printf(“Before reverse operation”);

print(array , size);

printf(“After reverse operation”);

left = array;

right = (array+size)-1;

while (left<right)

{

*temp=*left ;

*left=*right;

*right = *left ;

left++;

right–;

}

print(array,size);

getch();

}

void scanarray(int *a,int size)

{

int *end = (a+size-1);

while(a<=end)

{

scnaf(“%d”,a++);

}

}

void print(int *a, int size)

{

int *end = (a+size-1);

while(a<=end)

{

printf(“%d”,*(a++));

}

}

Example 4

write a program to searching operation in array using pointer.

इस उदहारण मे , pointer से किसी array मे searching operation के प्रोग्राम को discuss करगे |

Explanation

सबसे पहले header field मे , तीन user define functions को declare करेगे |

main function:

main function:

1.यूजर से array की size और elements को input करा लेते है |उसके बाद scanarray() function को call करते है जिसमे declare array name और size pass होती है |

2.उसके बाद जिस element को search करना है use यूजर से input करा लेते है |

3.उसके बाद searching() function को call किया जाता है , जिसमे declare array name , size , search element pass होती है |

4.search () के आधार पर प्राप्त आउटपुट को print करा लेते है |

scanarray() मे ,

इस function से , pointer से array मे यूजर द्वारा input की गयी values को assign किया जाता है |

1.सबसे पहले pointer variable end को set किया जता है |

2.जब तक pointer variable ‘a’ की value end से छोटी या equal होती है तब तक array मे value assign होती है |

print() मे

इस function से , array के elements को print किया जाता है |

1.सबसे पहले pointer variable end को set किया जता है |

2.जब तक pointer variable ‘a’ की value end से छोटी या equal होती है तब तक array मे value print होती है |

search()

1.सबसे पहले pointer variable end को set किया जता है |

2.फिर loop चलाया जाता है जिसमे search element को array के सभी element से check किया जाता है |

3.अगर search element array मे मिल जाता है तब उसका index return हो जाता है |

4.अगर search element नहीं मिलता है तब -1 return हो जाता है |

source code :

#include

#include

void scanarray(int *a,int size);

void print(int *a, int size);

int search(int *a ,int size , int search);

void main()

{

int s;

int *temp;

int array[size],size;

printf (“Enter Size”);

scanf(“%d”,&size);

printf (“Enter element that you want search”);

scanf(“%d”,&s);

printf(“Enter Elements”);

scanarray(array , size);

int count = search(array,size,s);

if(count == -1)

{

printf (“Enter element does not in array”);

}

else

{

printf(“%d is at %d in array.”,s,count);

getch();

}

void scanarray(int *a,int size)

{

int *end = (a+size-1);

while(a<=end)

{

scnaf(“%d”,a++);

}

}

void print(int *a, int size)

{

int *end = (a+size-1);

while(a<=end)

{

printf(“%d”,*(a++));

}

}

int search(int *a, int size , int search)

{

int *end = (a+size-1);

int index=0;

while (a<=end && *a != search)

{

a++;

index++;

}

if (index < end)

{

return index;

}

else

{

return -1;

}

}

Sbistudy

Recent Posts

four potential in hindi 4-potential electrodynamics चतुर्विम विभव किसे कहते हैं

चतुर्विम विभव (Four-Potential) हम जानते हैं कि एक निर्देश तंत्र में विद्युत क्षेत्र इसके सापेक्ष…

3 days ago

Relativistic Electrodynamics in hindi आपेक्षिकीय विद्युतगतिकी नोट्स क्या है परिभाषा

आपेक्षिकीय विद्युतगतिकी नोट्स क्या है परिभाषा Relativistic Electrodynamics in hindi ? अध्याय : आपेक्षिकीय विद्युतगतिकी…

5 days ago

pair production in hindi formula definition युग्म उत्पादन किसे कहते हैं परिभाषा सूत्र क्या है लिखिए

युग्म उत्पादन किसे कहते हैं परिभाषा सूत्र क्या है लिखिए pair production in hindi formula…

7 days ago

THRESHOLD REACTION ENERGY in hindi देहली अभिक्रिया ऊर्जा किसे कहते हैं सूत्र क्या है परिभाषा

देहली अभिक्रिया ऊर्जा किसे कहते हैं सूत्र क्या है परिभाषा THRESHOLD REACTION ENERGY in hindi…

7 days ago

elastic collision of two particles in hindi definition formula दो कणों की अप्रत्यास्थ टक्कर क्या है

दो कणों की अप्रत्यास्थ टक्कर क्या है elastic collision of two particles in hindi definition…

7 days ago
All Rights ReservedView Non-AMP Version
X

Headline

You can control the ways in which we improve and personalize your experience. Please choose whether you wish to allow the following:

Privacy Settings
JOIN us on
WhatsApp Group Join Now
Telegram Join Join Now