bsc

Comprehensive codebase and cou...
Log | Files | Refs | README | LICENSE

commit 390a9048d8c646fa6440a06be082f6349e06fb96
parent 075d999cc128548dfc316427e468cd5c681fa6af
Author: Amit Dutta <amitdutta4255@gmail.com>
Date:   Tue,  7 Oct 2025 13:01:34 +0530

new problem 7

Diffstat:
Aletusc/lucproblem007.c | 39+++++++++++++++++++++++++++++++++++++++
1 file changed, 39 insertions(+), 0 deletions(-)

diff --git a/letusc/lucproblem007.c b/letusc/lucproblem007.c @@ -0,0 +1,38 @@ +/* Two numbers are entered through the keyboard. Write a program to +find the value of one number raised to the power of another */ +/* Author - Amit Dutta, Date - 07th OCT, 2025 */ +/* Let Us C, Chap - 5, Page - 84, Problem 5.3 */ + +#include <stdio.h> +int main() +{ + double num, result; + int power, i = 1; + printf("Enter the numbers in 'num^power' format : "); + // checking if the input is valid or not + if (scanf("%lf^%d", &num, &power) != 2) + { + printf("\nPlease enter numbers."); + return 1; + } + // result for the negetive input + if (power < 0) + { + printf("\nPlease use a positive number as power."); + return 1; + } + // Hard codded result for input '0' (zero) + if (power == 0) + { + printf("\n%g to the power of %d is : 1", num, power); + return 0; + } + result = num; + while (i <= power - 1) + { + result = result * num; + i++; + } + printf("\n%g to the power of %d is : %g", num, power, result); + return 0; +}+ \ No newline at end of file
© notamitgamer • Site Built: 2026-07-21 13:58:23 UTC • git-mirror commit: 1037f62 [view raw info]
Originally created with stagit • modified by notamitgamer
Forked from github.com/notamitgamer/git-mirror