Javatpoint Logo
Javatpoint Logo

4. C program to print all pronic numbers between 1 to 100.

Pronic number is a product of two consecutive integers of the form: n(n+1).

For example:

Some pronic numbers are: 0, 2, 6, 12, 20, 30, 42, 56 etc.

In this program, we need to print all pronic numbers between 1 and 100 by following the algorithm as given below:

ALGORITHM:

  • STEP 1: START
  • STEP 2: PRINT statement "Pronic numbers between 1 and 100:"
  • STEP 3: SET i=1. REPEAT STEP 4 and STEP 5 UNTIL i<=100
  • STEP 4: if (isPronicNumber(i)) then PRINT i
  • STEP 5: i=i+1.
  • STEP 6: RETURN 0
  • STEP 7: END

isPronicNumber(int num)

  • STEP 1: START
  • STEP 2: flag =false
  • STEP 3: SET j=1. REPEAT STEP 4 and STEP 5 UNTIL j<=num
  • STEP 4: if((j*(j+1))==num)
                  then flag = true
                  break
  • STEP 5: j=j+1
  • STEP 6: RETURN flag
  • STEP 7: END

PROGRAM:

Output:

Pronic numbers between 1 and 100:
2  6  12  20  30  42  56  72  90
Next TopicC Programs





Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA