Merge branch 'document/math' into document/temp

* document/math:
  replace printf & scanf with std::cout and std::cin
  documented factorial
This commit is contained in:
Krishna Vedala 2020-05-28 16:50:13 -04:00
commit 76278a76c8
No known key found for this signature in database
GPG Key ID: BA19ACF8FC8792F7
2 changed files with 11 additions and 8 deletions

View File

@ -1,14 +1,17 @@
// C++ program to find factorial of given number
#include<iostream>
/**
* @file
* @brief C++ program to find factorial of given number
*/
#include <iostream>
// function to find factorial of given number
/** function to find factorial of given number */
unsigned int factorial(unsigned int n) {
if (n == 0)
return 1;
return n * factorial(n - 1);
}
// Driver code
/** Main function */
int main() {
int num = 5;
std::cout << "Factorial of " << num << " is " << factorial(num)

View File

@ -81,10 +81,10 @@ void power(int x, int n) {
/** Main function */
int main() {
int exponent, base;
printf("Enter base ");
scanf("%id \n", &base);
printf("Enter exponent ");
scanf("%id", &exponent);
std::cout << "Enter base ";
std::cin >> base;
std::cout << "Enter exponent ";
std::cin >> exponent;
power(base, exponent);
return 0;
}