You are here:

C/need help to solve a question

Advertisement


Question
write a program to rotate their values such that x has y,y has z and z has x value.

Answer
Hi dear Manny !

Swapping values between variable is of course very simple with the help of a third party typically a temporary variable , but it sounds bit difficult if you are restricted to use the third party (Temporary variable) Presenting you a simple solutoin to shift the contents using the help of temporary variable !


#include<stdio.h>
void main()
{
  int x , y , z , temp;

  x = 1; y = 2 ; z = 3;

  temp = x;
  x = y;
  y = z;
  z = temp;
  printf("After rotating :");
  printf("X = %d\n" , x);
  printf("Y = %d\n" , y);
  printf("z = %d\n" , z);
}


If you are looking code for the yet technique do revert me !

Thanks and Regards !
Prince M. Premnath

C

All Answers


Answers by Expert:


Ask Experts

Volunteer


Prince M. Premnath

Expertise


I'm sure that I can solve any doubts in Turbo C ,Graphics Programing ,Mouse, Hardware Programming ,File System ,Interrupts, BIOS handling , TSR Programming , General Concepts in C Language, handling inline Assembly statements

Experience

Research over 6+ Years

Organizations
CG-VAK Softwares and Exports Limited

Education/Credentials
Masters in Computer Applications

©2012 About.com, a part of The New York Times Company. All rights reserved.