- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Environmental Science
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Write C Program to Calculate Addition of All Elements in Array
Program : Addition of All Elements of the Array
#include <stdio.h>
int main() {
int i, arr[50], sum, num;
printf("\nEnter no of elements :");
scanf("%d", &num);
//Reading values into Array
printf("\nEnter the values :");
for (i = 0; i < num; i++)
scanf("%d", &arr[i]);
//Computation of total
sum = 0;
for (i = 0; i < num; i++)
sum = sum + arr[i];
//Printing of all elements of array
for (i = 0; i < num; i++)
printf("\na[%d]=%d", i, arr[i]);
//Printing of total
printf("\nSum=%d", sum);
return (0);
}
Output :
Enter no of elements : 3
Enter the values : 11 22 33
a[0]=11
a[1]=22
a[2]=33
Sum=66
- Related Questions & Answers
- How to read the values of x, y and z and print the results expressions in one line using C Program
- How to Calculate Area of Equilatral Triangle using C Language
- Write C Program to Reversing an Array Elements in C Programming
- How to calculate sum of 5 subjects and find percentage Using C Program
- How to find area and circumference of circle using C Programming
- Write C Program to Find Largest Element in Array in C Programming
- How to Solve Second Order Quadratic Equation Using C Program
- How to find gretest in 3 number using C Programming
- How to Check Whether Number is Perfect Or Not using C
- Write a ‘C’ Program to compute the sum of all elements stored in an array using pointers
- How to calculate gross salary of a person using C Program
- How to Find Area of Scalene Triangle using C
- Find Second largest element in an array using C Programming
- How to Calculate Area of Rectangle using C Program
- Write C program to find Exponent Power Series
- How to Implement Stack Operations Using Array using C
Advertisements
ads