Develop menu- driven c program to
perform following pointer
operations:
1.exchange(swap) values of two
variables
2. add two numbers
guys it's urgent
Answers
Answered by
0
Answer:
/*C program by Chaitanya for beginnersbook.com
* Program to swap two numbers using pointers*/
#include <stdio.h>
// function to swap the two numbers
void swap(int *x,int *y)
{
int t;
t = *x;
*x = *y;
*y = t;
}
int main()
{
int num1,num2;
printf("Enter value of num1: ");
scanf("%d",&num1);
printf("Enter value of num2: ");
scanf("%d",&num2);
//displaying numbers before swapping
printf("Before Swapping: num1 is: %d, num2 is: %d\n",num1,num2);
//calling the user defined function swap()
swap(&num1,&num2);
//displaying numbers after swapping
printf("After Swapping: num1 is: %d, num2 is: %d\n",num1,num2);
return 0;
}
Similar questions
English,
15 days ago
Math,
15 days ago
Geography,
30 days ago
Hindi,
30 days ago
Computer Science,
8 months ago