■Write a program to check whether a number is a Niven number or not.■
#Computer student....
Answers
Answered by
2
Answer:
Here is your answer, mate.
Mark as Brainliest.
Explanation:
#include<studio.h>
#include<conio.h>
void main()
{
int a;
clrscr();
printf("Enter the value of 'a');
scanf("%d,"&a);
if (n%2==0);
printf("The given number is even");
else
printf("The given number is odd");
getch();
}
Answered by
4
The program is given below:
import java.util.*;
class Niven
{
public static void main(String args[])
{
Scanner sc = new Scanner(System.in);
int num,sum=0,d,p;
System.out.println("Enter the number:");
num = sc.nextInt();
p = num;
do
{
d = num%10;
sum = sum+d;
num = num/10;
}
while(n!=0);
if(p%sum==0)
System.out.println("The number is Niven.");
else
System.out.println("The number is not Niven.");
}
}
Similar questions