write a function which accept two numbers from main() and
interchange them using pointers?
Answer Posted / amritpal singh
#include<iostream.h>
#include<conio.h>
void main()
{
int a,b;
void swap(int *,int *); //Functioin Prototype
clrscr();
cout<<"\nEnter the number::\n";
cin>>a>>b;
cout<<"\nValues before INterchange are \na=<<" and \nb="<<b;
swap(&a,&b); //Functiion Calling
cout<<"\nValues after interchange\na=<<" and \nb="<<b;
getch();
}
void swap(int *a,int *b) //Function Defintioon
int temp;
temp=*a;
*a=*b;
*b=temp;
}
Thanks friends if any mistake pls coorect it by again urs
answer
| Is This Answer Correct ? | 2 Yes | 2 No |
Post New Answer View All Answers
Can a variable be both constant and volatile?
Subtract Two Number Without Using Subtraction Operator
What is the difference between break and continue?
Explain what are the different data types in c?
What is an array? What the different types of arrays in c?
What does it mean when a pointer is used in an if statement?
What is extern keyword in c?
What is #line in c?
What are compound statements?
What is the difference between procedural and functional programming?
Explain null pointer.
What is the size of array float a(10)?
Do pointers need to be initialized?
Explain the difference between null pointer and void pointer.
How can I change the size of the dynamically allocated array?