// c program to add 10 elements entered by the user
#include <stdio.h>
int main ()
{
int i;
float elements[10]; //declaring the array
float sum = 0;
for (i = 0; i < 10; ++i)
{
printf ("Enter element %d: ", i + 1); //getting the elements from the user
scanf ("%f", &elements[i]); //storing the elements
sum += elements[i]; //adding integers entered by the user to the sum variable
}
printf ("sum of above entered elements is : %.4f", sum); //printing the sum to four decimal places
return 0;
}
jkamugisha 0 Newbie Poster
jkamugisha 0 Newbie Poster
rproffitt 2,662 "Nothing to see here." Moderator
jkamugisha 0 Newbie Poster
rproffitt 2,662 "Nothing to see here." Moderator
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.