Pascal Triangle program that needs to convert from C to C#

Please support our C advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Oct 2008
Posts: 6
Reputation: tcoma4x4 has a little shameless behaviour in the past 
Solved Threads: 0
tcoma4x4 tcoma4x4 is offline Offline
Newbie Poster

Pascal Triangle program that needs to convert from C to C#

 
0
  #1
Oct 15th, 2008
Hi All,

I have this old c program that I did a while back on pascals triangle and i'm trying to convert it over to c#.net. Can anyone help me do this? I do not know much or anything on on c#

Here is the code:
  1. //Lyncob directory
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. int main()
  5. {
  6. int numberOfLevels, i, j , k, spaces = 5;
  7. printf ( "How many rows you want to show?: ");
  8. scanf ( "%d", & numberOfLevels);
  9. for ( i = 0; i < numberOfLevels; i ++ )
  10. {
  11. int currentElement = 1;
  12. k = 0;
  13. while ( k < spaces )
  14. {
  15. printf ( " " );
  16. k ++;
  17. }
  18. for ( j = i; j >= 0; j -- )
  19. {
  20. printf ( " %d", currentElement );
  21. currentElement = currentElement * j / ( i - j + 1 );
  22. }
  23. printf("\n");
  24. spaces --;
  25. }
  26. }
Last edited by Narue; Oct 15th, 2008 at 3:17 pm. Reason: added code tags
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



Tag cloud for C
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC