Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


write a function which accept two numbers from main() and
interchange them using pointers?

Answers were Sorted based on User's Feedback



write a function which accept two numbers from main() and interchange them using pointers?..

Answer / sarathi

#include<stdio.h>
main()
{
int *p,*q;
*p=10;
*q=20
void swap(int &p,int &q);
}
void swap(int *x,int *y);
{
int *tmp;
*tmp=*x;
*x=*y;
*y=*x;
printf("%d,%d",*x,*y);
}

Is This Answer Correct ?    5 Yes 4 No

write a function which accept two numbers from main() and interchange them using pointers?..

Answer / 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

write a function which accept two numbers from main() and interchange them using pointers?..

Answer / vignesh1988i

#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,*ptr1,*ptr2,temp;
printf("enter the values ");
scanf("%d%d",&a,&b);
ptr1=&a;
ptr2=&b;
temp=(*ptr1);
*ptr=(*ptr2);
*ptr2=temp;
printf("\n now the values are a=%d b=%d ",a,b);
getch();
}


thank u

Is This Answer Correct ?    4 Yes 5 No

Post New Answer

More C Interview Questions

Do you know the purpose of 'register' keyword?

0 Answers  


Is the following code legal? struct a { int x; struct a b; }

4 Answers  


please can any one suggest me best useful video tutorials on c i am science graduate.please help me.u can email me to sas29@in.com

0 Answers  


Should I learn c before c++?

0 Answers  


1) int main() { unsigned char a = 0; do { printf("%d=%c\n",a,a); a++; }while(a!=0); return 0; } can anyone please explain the explain the output

2 Answers  


What is C++

4 Answers  


main() { int i=5; printf("%d%d%d%d",i++,i--,i); }

10 Answers  


How do I determine whether a character is numeric, alphabetic, and so on?

0 Answers  


What is hashing in c?

0 Answers  


what is computer

4 Answers  


Explain the array representation of a binary tree in C.

0 Answers   Genpact,


Is there any data type in c with variable size?

0 Answers  


Categories