C Program to accept two numbers and interchange two values using functions
#include<conio.h>
#include<stdio.h>
void swap (int a, int b);
main( )
{
int a,b;
clrscr( );
printf(“enter value for a;”);
scanf(“%d”,&a);
printf(“enter value for b;”);
scanf(“%d”,&b);
swap(a,b);
getch( );
}
void swap(int a,int b)
}
int c;
c=a;
a=b;
b=c;
printf(“\na=%d”,a);
printf(“\nb=%d”,b);
}
C Program to accept two numbers and interchange two values using functions
This program accepts two numbers from the user and then it is going to inter change two values using the functions. The functions will be used to accomplish this purpose.
#include
#include
#define MAX 1000
int main()
{
long int num1,num2,num3,num4,n=0;
printf("Enter the first number\n");
scanf("%ld",&num1);
printf("Enter the second number\n");
scanf("%ld",&num2);
printf("The third number is %ld\n", num1+num2);
printf("The fourth number is %ld\n", num1-num2);
printf("The fifth number is %ld\n", num1/num2);
printf("The sixth number is %ld\n", num1*num2);
printf("The seventh number is %ld\n", num1/num2);
printf("The eighth number is %ld\n", num1-num2);
printf("The ninth number is %ld\n", num1+num2);
printf("The tenth number is %ld\n", num1+num2);
return 0;
}