Pointer

Null Pointer in C

In this tutorial you will learn about null pointer in C with examples. When we declare a pointer, by default it points to some random memory location. If you will access the pointer then it may give some undesired value or the program may crash. What is Null Pointer in C? A pointer pointing to …

Null Pointer in C Read More »

C++ program to swap two numbers using pointers

#include<iostream.h> #include<conio.h> void main() { clrscr(); int *a,*b,*temp; cout<<“Enter value of a and b:”; cin>>*a>>*b; temp=a; a=b; b=temp; cout<<“nAfter swapingna=”<<*a<<“nb=”<<*b; getch(); }

C program to swap two numbers using pointers

#include<stdio.h> #include<conio.h> void main() { int *a,*b,*temp; clrscr(); printf(“Enter two mumbers:”); scanf(“%d%d”,a,b); printf(“Before Swaping:na=%d b=%d”,*a,*b); temp=a; a=b; b=temp; printf(“nAfter Swaping:na=%d b=%d”,*a,*b); getch(); }