- 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
- articles and Answers
- Effective Resume Writing
- HR Interview articles
- 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
- Write C Program to Delete duplicate elements from an array
- Write C program to Check Whether a Number is Positive or Negative
- Write C Program For Finding The Length Of Loop In Linked List
- How to Calculate Area of Rectangle using C Program
- C Program To Print Your Own Name
- How to check the type of triangle using C
- How to read the values of x, y and z and print the results expressions in one line using C Program
- How to find area and circumference of circle using C Programming
- How to Implement Stack Operations Using Array using C
- Write C Program to Calculate Addition of All Elements in Array
- Write C Program to Reversing an Array Elements in C Programming
- How to calculate gross salary of a person using C Program
- Write C Program to Find Smallest Element in Array in C Programming
- How to Calculate Area of Equilatral Triangle using C Language
- How to print hello world using C Language
- Recursive program to linearly search an element in a given array using C
Advertisements
ads