Untitled
unknown
plain_text
a month ago
810 B
2
Indexable
#include <stdio.h> int main() { int n; long long product = 1; // Using long long to handle large product values // Ask user for the number of values to multiply printf("Enter the number of values you want to multiply: "); scanf("%d", &n); // Input validation if (n <= 0) { printf("Please enter a positive integer for the number of values.\n"); return 1; } // Loop to get each number and multiply for (int i = 1; i <= n; i++) { int num; printf("Enter number %d: ", i); scanf("%d", &num); product *= num; // Multiply the current number with the running product } // Output the final product printf("The product of the entered numbers is: %lld\n", product); return 0; }
Editor is loading...
Leave a Comment