www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/04/21/02:33:16

From: "Johhny" <zieglmeier AT nisa DOT net>
Newsgroups: comp.os.msdos.djgpp
Subject: Base Case???
Date: 20 Apr 98 04:07:17 GMT
Organization: Okanagan Internet Junction
Lines: 20
Message-ID: <01bd6c13$2bbfa400$69d8c2cf@zieglmeier>
NNTP-Posting-Host: news.nisa.net
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Im a new programmer .Does anyone know the base case in this recursive
function?

#include <iostream.h>
int numActs=0;
void PrintStars(int n)     //Recursive function
{ numActs++;
  if(n>=1)
  {   for(int i=1;i<=n;i++)
		  cout<<"*";
	  cout<<endl;
	  PrintStars(n/2);
  }
}
void main()
{ PrintStars(8);
  cout<<"Total number of activations is "
		<<numActs<<endl;
}
zieglmeier AT nisa DOT net

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019