Right Click to Search

Tuesday, December 29, 2024

Addition of All Elements in Array


#include
#include
void main()
{
 int i,a[50],sum,n;
 printf("\n Enter no of elements :");
 scanf("%d",&n);
 /* Reading values into Array */
 printf("\n Enter the values :");
 for(i=0;i 〈 n;i++)
 scanf("%d",&a[i]);
 /* computation of total */
 sum=0;
 for(i=0;i 〈 n;i++)
 sum=sum+a[i];
 /* printing of all elements of array */
 for(i=0;i 〈 n;i++)
 printf("\n a[%d]=%d",i,a[i]);
 /* printing of total */
 printf("\n sum=%d",sum);
}

Bookmark & Share

Tags / Keywords : |

Stumble
Delicious
Technorati
Twitter
Facebook

0 Comments:

Post a Comment

Your Feedback :This is Growing Site and Your Feedback is important for Us to improve the Site performance & Quality of Content.Feel Free to contact and Please Provide Name & Contact Email

 

Learn C Programming Copyright © 2010 LKart Theme is Designed by Lasantha, Free Blogger Templates