Tuesday, December 6, 2011

Write a C Program to swapping value until user stop

#include <stdio.h>
#include <conio.h>
void main()
{
 int i,a,b;
 char s[10];
 clrscr();
 for(i=0;;i++)
 {
  printf("A= ");
  scanf("%d",&a);
  printf("B= ");
  scanf("%d",b);
  if(a==b)
  {
   printf("Try again with different value");
   printf("If you continue type Y other wise N: ");
   scanf("%s",&s);
   if(s=="y")
   {
    continue;
   }
   else
   {
    break;
   }
  }
  else
  {
   printf("\n\n\nAfter Swappint...\nA= %d\nB= %d",b,a);
   printf("If you continue type Y other wise N: ");
   scanf("%s",&s);
   if(s=="y")
   {
    continue;
   }
   else
   {
    break;
   }
  }
 }
 getch();
}

No comments:

Post a Comment