current position:Home>Prompt the user to enter an integer n and N real numbers, calculate and output the sum of the negative numbers in the input n real numbers.

Prompt the user to enter an integer n and N real numbers, calculate and output the sum of the negative numbers in the input n real numbers.

2022-02-02 17:43:40 CSDN Q & A

How to program
How to run in multiple ways
Ball boss help




Refer to the answer 1:
#include <stdio.h>int main(void) {     printf(" Input n:");    int n;    scanf("%d",&n);    printf(" Input %d A real number :", n);    int a[1000];    for(int i=0;i<n;i++){        scanf("%d", &a[i]);    }    int sum=0;    for(int i=0;i<n;i++){        if(a[i]<0)sum+=a[i];    }    printf(" Sum of negative numbers :%d", sum);    return 0;}



Refer to the answer 2:

copyright notice
author[CSDN Q & A],Please bring the original link to reprint, thank you.
https://en.primo.wiki/2022/02/202202021743380807.html

Random recommended