Computer Science, asked by 2adi, 1 year ago

a program to check whether a number is pronic or not

Answers

Answered by cynthiarai
2
int main(){
//1
int no;
int i;
int flag = 0;
//2
printf("Enter a number to check : "); scanf("%d",&no);
//3
for(i=0; i<=no ;i++){ //4 if(i*(i+1) > no){
break;
}
//5
if(i*(i+1) == no){
printf("The input number is a Pronic number.\n");
flag = 1;
break;
}
}
//6
if(!flag){
printf("The input number is not a Pronic number.\n");
}
}
I hope it helps!

2adi: thanks...
cynthiarai: welcome
cynthiarai: please make me a brainilist
Answered by BrainlyPromoter
1

  • A pronic number is a type of number which is a product of any two consecutive integers.
  • It's a Java program i.e. the following program is written in Java programming language.

import java.util.Scanner;

public class PronicNumber

{

   public static void main(String brain[])

   {

       Scanner promo=new Scanner(System.in);

       System.out.println("Enter a number to be checked.");

       int n=promo.nextInt();

       for(int k=1;k<=n;k++)

       {

           if(n%k==0)

           {

               if((k+1)*i==n||(k-1)*i==n)

               {

                   System.out.println("Entered number is Pronic.");

                   break;

               }

               else    

               {

                   System.out.println("No, the number is not Pronic number.");

                   break;

               }

           }            

       }

   }

}

Similar questions