Computer Science, asked by hasini5365, 2 months ago

write a program to accept a number and print the average of its digits​

Answers

Answered by Anonymous
1

Answer:

  1. #inculde<iostream.h>
  2. #include<conio.h>
  3. void main()
  4. cout<<"What's the Total no. of number"
  5. cin>>avg_1
  6. if (avg_1 = 2):
  7. cout<<"Enter First Number"
  8. cin>>no_1
  9. cout<<"Enter Second Number"
  10. cin>>no_2
  11. outcome = 1+2
  12. final_outcome = outcome/2
  13. print<<"Average of ", no_1, " , ", no_2, " is ", final_outcome
  14. else:
  15. cout<<"Function Currently Unavailable "
  16. getch()

Explanation:

We have written the program in c++. I can write in python and Javascript too if you want. In Program, I have asked what's the total number of which you want to find out the average and then, after getting the input. I have used conditional statement if-else. You can use if-elif-else condition too if you want. When you users input that he wanted to find out average of 2 numbers then, I am awared now I have to divide the sum of 2 numbers by 2 as per formulae of average. If you want to add either 3 or 4 or any other number of total number then, you can go for it by using if-elif-else condition. After Finding average I have printed out the result. If user enters any number except 2 then, it will print the else statement. Same Way, You can go ahead for Your Program.

Plz Follow Me and Mark My answer Brainliest as Well as Rate my Answer 5 stars.

Similar questions