Sunday 8 April 2012

28).Write a Program to Swap a Variable by Using Pointer

#include<conio.h>
#include<iostream.h>

void main()
{
   clrscr() ;

   int *x,*y ,a=0,b=1, temp;
   x=&a;
   y=&b;
   temp=*x;
   *x=*y;
   *y=temp;
   cout<<"the value of x and y  "<<x<<" " <<y;
   cout<<"\nthe value of a  and b "<<a<<" "<<b;
   cout<<"\nthe value of *x  and *y is "<<*x<<" "<<*y;
   cout<<"\nthe value of &a  and &b is "<<&a<<" "<<&b;

   getch();

}

No comments:

Post a Comment

Write a program which reads a set of integers into an integer array and then prints "YES"if all of them are same otherwise print "NO".

#include<stdio.h> int main() { int a[10],M=0,i,n; printf("enter a value for n\n"); scanf("%d",&n); fo...