function to solve hanoi tower game

#include<stdio.h>
/*************************************************************************/
void towers(int n,char frompeg,char topeg,char auxpeg)
{
	if(n==1)
	{
	printf("\n%s%c%s%c","move disk 1 from peg ",frompeg," to peg ",topeg);
	return;
	}

	towers(n-1,frompeg,auxpeg,topeg);
	printf("\n%s%d%s%c%s%c","move disk ",n," from peg ",frompeg,
	"to peg",topeg);
	towers(n-1,auxpeg,topeg,frompeg);
}
/************************************************************************/
void main()
{
	int n;
	scanf("%d",&n);
	towers(n,'A','B','C');
}

Interesting, please try to stick to the Standard.
It's int main (void), not void main()

;) :idea: :rolleyes: :surprised :cool: :twisted: :p :?: :cheesy: :mrgreen: :) :!: :confused: :lol: :eek: :-| :mad: :sad: THATS MY COMMENT

commented: Twit -4

Is this C++ code? It looks like C code.

can this be done without recursion

commented: ToH has three pegs, your post is 3 YEARS too late - coincidence? -4

>>can this be done without recursion

Most likely, yes.