+ 1

[ASSIGNMENT] Multiplication of N numbers

User has to enter how many numbers (N with max. 5) they want to multiply and then enter the values. The output has to give the result of the multiplication of N numbers

4th Apr 2018, 3:17 PM
F A
F A - avatar
1 Answer
0
#include<stdio.h> int main(void) { int n, res=1; scanf("%d", &n); if (n == 0) { printf("0"); return 0; } int *t = (int*) malloc(n*sizeof(int)) ; for (int i=0; i<n; i++) res *= *(t+i); printf("%d", res); free(t) return 0; }
4th Apr 2018, 3:25 PM
Bartosz Pieszko
Bartosz Pieszko - avatar