visual c++ - How to find Square of a number inside a Factorial while loop in C? -


i'm trying create program not calculate factorial of number display output factorial less square of number.

these requirements: type in number between 3 9. displays in output both factorial , square. if factorial of number inserted less square of number, output string "gotcha!"

this code far. thank you

#pragma once #include <stdio.h> #define min 3 #define max 9 #define _crt_secure_no_warnings  int main() { int i, fact = 1, num; printf("enter number:\n"); scanf_s("%d", &num);  while (num >= min || num <= max) {     (i = 1; <= num; i++)     {         fact = fact*i;     }     if (num < min || num > max)     {         printf("out of range. please try again.\n");         scanf_s("%d", &num);     }     else     {         printf("factorial of %d is: %d\n", num, fact);         return 0;     } } } 

just calculate square of number multiplying itself.

square = num * num; printf("square of %d is: %d\n", num, square);  if (fact < square)     printf("gotcha!\n"); 

Comments

Popular posts from this blog

javascript - How to get current YouTube IDs via iMacros? -

c# - Maintaining a program folder in program files out of date? -

emulation - Android map show my location didn't work -