#include<stdio.h>
#include<conio.h>
void main()
{
 printf("enter number:");
 scanf("%d",&n);
 for(i=1;i<=y;i++)
 {
  x++;
 }
 t=x;

 for(i=1;i<=y;i++)
 {
  t--;
 }
 y=t;
 getch();
}

Until you really know what you're doing, it's a good idea to compile code you want to show off before posting it.

Edited 2 Years Ago by deceptikon

main.c:7:6: error: 'i' undeclared (first use in this function)
main.c:7:13: error: 'y' undeclared (first use in this function)
main.c:9:3: error: 'x' undeclared (first use in this function)
main.c:11:2: error: 't' undeclared (first use in this function)

Edited 2 Years Ago by Tumlee

#include<stdio.h>
#include<conio.h>
void main()
{
 int x,y,i,t;
 clrscr();
 printf("Enter x and y: ");
 scanf("%d%d",&x,&y);
 for(i=1;i<=y;i++)
 {
  x++;
 }
  t=x;
   for(i=1;i<=y;i++)
    {
     t--;
    }
     y=t;
      for(i=1;i<=y;i++)
      {
       x--;
      }
       printf("%d%d",x,y) ;

getch();  
}

Did you consider doing this with for loops a puzzle, or was that the only way you knew how to do it?

Your code from line 9 to 22 can be simplified to:

t = 0;
x = x + y;
t = x;
t = t - y;
y = t;
x = x - y;
This question has already been answered. Start a new discussion instead.