It is the "Tower of Hanoi" and it is a puzzle. When you can solve the puzzle you can write the program, when you have learned enough to write simple programs.
You do want to be able to write computer programs, don't you?
I don't use that function in C programme.
/* hanoi.c */ #include <stdio.h> #include <stdlib.h> static long step; static void Hanoi (int n, int from, int to,int spare) { if (n>1) Hanoi (n-1,from,spare,to); printf ("Step %ld: move #%d %d-->%d\n", ++step, n, from, to); if (n>1) Hanoi (n-1,spare,to,from); } int main (int argc, char **argv) { int n; if (argc==1 (n= atoi(argv[1]))<=0) n= 5; step= 0; Hanoi (n, 1, 2, 3); return 0; }
#include#includevoid hanoi(int x, char from,char to,char aux){if(x==1){printf("Move Disk From %c to %c\n",from,to);}else{hanoi(x-1,from,aux,to);printf("Move Disk From %c to %c\n",from,to);hanoi(x-1,aux,to,from);}}int main(void){int disk;clrscr();printf("Enter the number of disks you want to play with:");scanf("%d",&disk);double moves=pow(2,disk)-1;printf("\nThe No of moves required is=%g \n",moves);hanoi(disk,'A','C','B');getch();}
result = a * b * c;
If: a = b+c+d Then: c = a-b-d
There is nothing to solve. C = 43.96 cm!
answer:32 programme to print factorial of a given number in c languages
int main (void) { printf ("One line programme\n"); return 0; }
/* tower of hanoi using recursion */ #include<stdio.h> int main(void) { unsigned int nvalue; char snvalue = 'L' , invalue = 'C' , dnvalue = 'R' ; void hanoi(unsigned int , char , char , char); printf(" enter number of disks : "); scanf("%u",&nvalue ); printf("\n\ntower of hanoi problem with %d disks \n ", nvalue )" hanoi(nvalue , snvalue , invalue , dnvalue ); printf("\n"); return 0 ; } void hanoi(unsigned n , char snd1 , char ind1 , char dnd1 ) { if(n!=0) { /* move n-1 disks from starting to intermadiate needles */ hanoi(n-1 , snd1 , dnd1 , ind1 ); /* move disk n from start to destination */ printf("move disk %d from %c to %c\n ", n , snd1 , dnd1); /* move n-1 disks from intermediate to destination needle */ hanoi(n-1 , ind1 , snd1 , dnd1 ); } }
Any experssion including assignment or a function call can be a statement in C
#include<iostream.h>
String Quintet in C is the music that is played in the inspector Purbright Programme. It the music is played by Schubert.