Created
December 8, 2008 22:15
-
-
Save bryanwoods/33644 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// triangularNumber.m | |
// prog1 | |
// | |
// Created by Bryan Woods on 12/8/08. | |
// Copyright __MyCompanyName__ 2008. All rights reserved. | |
// | |
#import <stdio.h> | |
int main (int argc, char *argv[]) | |
{ | |
int n, number, triangularNumber, counter; | |
for ( counter =1; counter <= 5; ++counter ) { | |
printf("What triangular number do you want? "); | |
scanf("%i", &number); | |
triangularNumber = 0; | |
for ( n = 1; n <= number; ++n ) | |
triangularNumber += n; | |
printf("The triangular number %i is %i\n\n", number, triangularNumber); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment