write a program to find the sum of the array elements in c
language?

Answer Posted / mohd hayyan

#include<stdio.h>
#include<conio.h>
void main()
{
int a[i],i,sum=0;
clrscr();
printf("enter the array");
for(i=0;i<3;i++)
scanf("%d",&a[i]);
for(i=0;i<3;i++)
{
sum=sum+a[i];
}
for(i=0;i<3;i++)
{
printf("a[%d]=%d",i,a[i]);
}
printf("%d",sum);
getch();
}

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Write a simple code fragment that will check if a number is positive or negative.

713


what is the difference between class and unio?

1866


Write a program of advanced Fibonacci series.

712


Difference between Shallow copy and Deep copy?

1576


write a C program: To recognize date of any format even formats like "feb-02-2003","02-february-2003",mm/dd/yy, dd/mm/yy and display it as mm/dd/yy.

3343






What happens if you free a pointer twice?

615


What is the most efficient way to store flag values?

691


What is pointers in c?

663


Create a registration form application by taking the details like username, address, phone number, email with password and confirm password (should be same as password).Ensure that the password is of 8 characters with only numbers and alphabets. Take such details for 3 users and display the details. While taking input password must appear as “****”.

2652


Write a program to print ASCII code for a given digit.

692


Give a one-line C expression to test whether a number is a power of 2. [No loops allowed - it's a simple test.]

635


What is the use of #include in c?

585


What are the ways to a null pointer can use in c programming language?

593


How are pointers declared in c?

603


How is a macro different from a function?

660