Math, asked by Anonymous, 2 months ago

#include <stdio.h> int min(int X,int Y){ return (y<X)?Y:X; } int main() { int a[]={-5,9,8,-8,-2}; int z=a[0],n=5,i=b,c=a[0] for(i=1;i<n;i++){ c=mon(a[i],c+a[i]); z=Min​

Answers

Answered by kujursarita61
1

Answer:

yeh Kya h Bhai please jeldi bhethana

Answered by dreamrob
1

Given:

#include<stdio.h>

int min(int x, int y)  

{

return (y <x)? y: x;

}

int main()  

{

int a[] = {-5, 9, 8,-8, -2};

int z = a[0], n=5, i=0,c=a[0];

for(i = 1;i<n; i++)  

{

 c=min(a[i], c+a[i]);

 z = min(z, c);

}

printf("%d", z);

}

Output:

-10

Explanation:

a = {-5 , 9 , 8 , -8 , -2}

       0   1    2     3   4

z = a[0] = -5

n = 5

i = 0

c = a[0] = -5

Loop:

i       c=min(a[i], c+a[i])       z=min(z, c)

1       c=min(a[1],c+a[1])       z=min(-5,4)

       c=min(9,-5+9)            z=-5

       c=min(9,4)

       c=4

2       c=min(a[2],c+a[2])       z=min(-5,8)

        c=min(8,4+8)               z=-5

        c=min(8,12)

        c=8

3       c=min(a[3],c+a[3])       z=min(-5,-8)

        c=min(-8,8-8)               z=-8

        c=min(-8,0)

        c=-8

4       c=min(a[4],c+a[4])       z=min(-8,-10)

        c=min(-2,-8-2)               z=-10

        c=min(-2,-10)

        c=-10

z = -10

So, output is equal to -10

Similar questions