Home
About
Desclaimer
Privacy Policy
Terms of Services
Python
C/C++
Java
HTML/CSS
Home
About
Desclaimer
Privacy Policy
Term of Services
Python
C/C++
Java
HTML/CSS
Ad Code
Responsive Advertisement
Categories
C Program
(10)
c++ Programs
(3)
Search This Blog
Powered by Blogger
December 2022
13
Report Abuse
About Me
Universal Programmers
View my complete profile
Home
C Program
Write a program in C to read 5 integer values from the user in an array, find and display the sum of all elements of an array.
Write a program in C to read 5 integer values from the user in an array, find and display the sum of all elements of an array.
Universal Programmers
December 30, 2022
Answer
Copy
#include
#include
int main(void) { / Declare an array to store the integers int arr[5]; / Read the integers from the user printf("Enter 5 integers: "); for (int i = 0; i < 5; i+ +) { scanf("%d", &arr[i]); }/ Initialize a variable to store the sum int sum = 0; / Calculate the sum of the elements of the array for (int i = 0; i < 5; i++) { sum += arr[i]; }/ Print the sum printf("Sum: %d\n", sum); return 0; }
OUTPUT
C Program
Post a Comment
0 Comments
Social Plugin
Popular Posts
Subscribe Us
Facebook
Tags
Close Menu
0 Comments