diff --git a/Product Of Array Except Self b/Product Of Array Except Self new file mode 100644 index 00000000..abedca36 --- /dev/null +++ b/Product Of Array Except Self @@ -0,0 +1,35 @@ +/* +Given an integer array nums, return an array answer such that answer[i] is equal to the product of all the elements of nums except nums[i]. +The product of any prefix or suffix of nums is guaranteed to fit in a 32-bit integer. +You must write an algorithm that runs in O(n) time and without using the division operation. +*/ + +/* +Input: nums = [1,2,3,4] +Output: [24,12,8,6] +*/ + +/* +Input: nums = [-1,1,0,-3,3] +Output: [0,0,9,0,0] +*/ + +#include +using namespace std; +int main() +{ + int a[100],b[100],n,mult=1; + cout<<"Enter the number of elements in the array: "; + cin>>n; + cout<<"Enter the elements of the array: "; + for(int i=0;i>a[i]; + mult = mult * a[i]; + } + for(int i=0;i +#include +#include +main() +{ + + char a[1000]; + printf(" ENTER A STRING\n"); + scanf("%[^\n]s",a); + char b[strlen(a)]; + strcpy(b,a); + printf("copied string: %s",b); + printf("\n %d are the number of characters copied",strlen(a)); + getch(); +}