Q-4.Write a C program to swap the values of two integer variables using extra variable.

0
অতিরিক্ত পরিবর্তনশীল ব্যবহার করে দুটি পূর্ণসংখ্যা ভেরিয়েবলগুলির মানগুলি স্য্যাপ করতে, একটি সি প্রোগ্রাম লিখুন।
  1. //Write a C program to swap the values of two integer variables using extra variable.
  2. #include <stdio.h> 
  3. int main()
  4. {
  5.    int a, b;
  6.    
  7.    printf("Input two integers (a & b) to swap\n");
  8.    scanf("%d%d", &a, &b);
  9.    
  10.    a = a + b;
  11.    b = a - b;
  12.    a = a - b;
  13.  
  14.    printf("a = %d\nb = %d\n",a,b);
  15.    return 0;
  16. }

Post a Comment

0Comments
Post a Comment (0)