C Online Compiler
Example: Plus Minus Program in C Language
C
C++
C#
Java
Python
PHP
main.c
STDIN
Run
// Plus Minus Program in C Language #include <stdio.h> int main() { int s=0; printf("Enter the size of the array::\n"); scanf("%d", &s); float arr[s]; printf("Enter the %d elements of the array::\n", s); // It will read the inputs of the array's elements + calculate the plus-minus values int i=0; float r1=0,r2=0,r3=0; while (i<s) { scanf("%f", &arr[i]); if (arr[i] > 0) r1++; if (arr[i] < 0) r2++; if (arr[i] == 0) r3++; i++; } r1 = r1/s; r2 = r2/s; r3 = r3/s; // It will print the final output printf("\n\n%0.6f\n%0.6f\n%0.6f\n", r1,r2,r3); return 0; }
6 4 1 -4 3 -9 0
Output
Clear
ADVERTISEMENTS