Computer Science, asked by agupoochi, 3 months ago

SPECIAL NUMBER
Write a program to get input from the user and find the number
is special number or not.
A 2-digit number is said to be a special number if the sum of the
sum of its digits and the products of its digits is
equal to the number itself.
For example, 19 is a special number. The digits in 19 are 1 and
9. The sum of the digits is 10 and the product of the
digits is 9.
10+9 = 19.
Comalo​

Answers

Answered by anindyaadhikari13
2

Answer:

This is the required C program for the question.

#include <stdio.h>

int main () {

int n,fd,ld,x;

printf("Enter a number - ");

scanf("%d",&n);

fd=n/10;

ld=n%10;

x=fd+ld+fd*ld;

if(n==x)

printf("Special Number.");

else

printf("Not a Special Number.");

return 0;

}

Explanation:

  1. Line 1: Include the standard input output header file.
  2. Line 2: Beginning of main() function. (Starting of execution point)
  3. Line 3: Declares the variable necessary for the program.
  4. Line 4: Ask the user to enter the number.
  5. Line 5: Number is taken as input.
  6. Line 6: Calculates the first digit and store it in variable fd.
  7. Line 7: Calculates the last digit and store it in variable ld.
  8. Line 8: Find the product and sum of digits and add them and store the result in x.
  9. Line 9: Check if number is equal to x.
  10. Line 10: If true, number is a special number. Display the message.
  11. Line 11: Else block.
  • Line 12: Display the message that the number is not a special number.
  1. Line 13: returns 0.
  2. Line 14: Close of main.

See the attachment for output ☑.

Attachments:
Similar questions