write a function which accept two numbers from main() and
interchange them using pointers?
Answers were Sorted based on User's Feedback
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 |
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 |
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 |
Linked list is a Linear or non linear explain if linear how it working as a non linear data structures
What is an example of enumeration?
what value is returned to operating system after program execution?
What are the three constants used in c?
write a reverse string to print a stars.(with out using logic) ***** **** *** ** *
what will be the output: main(){char ch;int a=10;printf("%d",ch);}
36 Answers Accenture, TCS, Wipro,
What is 2 d array in c?
why TCS selected more student in the software field from all institution.
When should the const modifier be used?
Write a C function to search a number in the given list of numbers. donot use printf and scanf
What is #include cctype?
A c program to display count values from 0 to 100 and flash each digit for a secong.reset the counter after it reaches 100.use for loop,. pls guys hepl me.. :(