‘C’ program to accept two integers from the user and interchange them.

C File =>



/* Write a ‘C’ program to accept two integers from the user and interchange them. Display the interchanged numbers.*/

#include<stdio.h>
int main() 
{
       int n1,n2,temp;
       printf("\n Enter value for n1 : ");
       scanf("%d",&n1);
       printf("\n Enter value for n2 : ");
       scanf("%d",&n2);
       temp=n1;
       n1=n2;
       n2=temp;
       printf("\n After swapping \n ");
       printf("n1=%d\tn2=%d",n1,n2);
   return 0;
}

Comments

Popular posts from this blog

Write a program to allocate memory dynamically for n integers. Accept the elements and calculate their sum and average

C program to accept names of n cities and search for city named “Pune”.