Page 1 of 1

Tough C Programme of Winter 2007, Section A (D)

PostPosted: Sun May 06, 2012 10:02 pm
by RAVIGARU
Problem is Attached and output screen shot is attached

programme:
----------------------------------------------------------------------------------------------
#include <stdio.h>
int main (void)
{
int triangular, loopcount, total;

loopcount = 0;
total = 0;
printf ("Enter number: ");
scanf ("%d", &triangular);

printf("IN ADDITION TO THE OUTPUT AS REQUIRED IN THE PROBLEM IT DISPLAYS\n");
printf("THE ALL POSSIBLE TRIANGULAR NUMBERS BETWEEN 0 AND N\n");
while (total < triangular)
{
/*IN ADDITION TO THE OUTPUT AS REQUIRED IN THE PROBLEM IT
DISPLAYS THE ALL POSSIBLE NUMBERS BETWEEN 0 AND N*/

printf("Possible triangular numbers: %d\n", total);
loopcount = loopcount+1;
total = total + loopcount;
}
if (triangular == total)

printf ("The give number %d is trinagular: %d\n", triangular, triangular == total);

else
printf ("The given number %d is non-trinagular: %d", triangular, triangular == total);

getch ();
}