Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // prufung.cpp : Defines the entry point for the console application.
- //
- #include "stdafx.h"
- float calc(float arr[], int anzahl )
- {
- float summe = 0;
- for (int i = 0; i < anzahl; i++)
- {
- summe += arr[i];
- }
- for (int i = 0; i < anzahl; i++)
- {
- arr[i] = summe - arr[i];
- }
- for (int i = 0; i < anzahl; i++)
- {
- printf("arr[%d] = %f\n", i, arr[i]);
- }
- return summe;
- }
- int main()
- {
- float w[65];
- int nw;
- printf("Geben Sie die Anzahl der Elemente ein:\n");
- scanf_s("%d", &nw);
- float Summe;
- if (nw > 65 || nw <1)
- {
- printf("Error.\n");
- return 0;
- }
- printf("Geben Sie die Elemente der Reihe ein:\n");
- for (int i = 0; i < nw; i++)
- {
- scanf_s("%f",&w[i]);
- }
- for (int i = 0; i < nw; i++)
- {
- printf("arr[%d] = %.2f\n", i, w[i]);
- }
- Summe = calc(w, nw);
- printf("Die Summe der Elemente = %.2f\n", Summe);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement