Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


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

Answers were Sorted based on User's Feedback



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

Answer / madhura musale

#include<stdio.h>
#include<conio.h>
void main()
{
int i,a[10],sum;
clrscr();
printf("\n Enter the elements in an array :");
for(i=0;i<10;i++)
scanf("%d",&a[i]);
printf("\n The sum of elements of an array are :");
for((i=0;i<10;i++)
sum=sum+a[i];
printf("\t %d",sum);
getch();
}

Is This Answer Correct ?    25 Yes 26 No

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

Answer / heemashree

#include "stdio.h"
#include "conio.h"
#include "stdafx.h"
void main()
{
int a[10];
int i,sum=0,n;

printf("enter number of elements");
scanf("%d",&n);



printf("Enter the array elements\n");
for (i=0; i<n; i++)
scanf("%d",&a[i]);

// sum of array elements
for (i=0; i<n; i++)
{
sum=sum+a[i];
}
printf("Sum of array elements===%d",sum);
}

Is This Answer Correct ?    0 Yes 1 No

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

Answer / bishmeet singh

#include<stdio.h>
#include<conio.h>
void main()
{
int a[10],i,n,sum=0;
printf("enter the no. of elements");
back:
scanf("%d",&n);
if(n<10)
{
printf("elements sholud be less than 10\n enter again");
goto back;
}
printf("Enter %d elements",n);
for(i=0;i<n;i++)
{
scanf("%d",a[i]);
sum=sum+a[i];
}

printf("sum of your entered elements is %d",sum);
getch();
}

Is This Answer Correct ?    0 Yes 2 No

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

Answer / sasa zezo

please help me i can't understand this program?


#include<stdio.h>
#include<stdlib.h>
struct node
{
int data;
struct node *next;
};
struct node *create(int n)
{
struct node *head;
head=(struct node*)malloc(sizeof(struct node));
if(head==NULL)
{
printf("no memory space");
exit(0);
}
else
{
head->data=n;
head->next=NULL;
}
return head;
}
void print(struct node * p)
{
printf("\n the new linked list is \n");
while(p!=NULL)
{
printf(" %d \t ",p->data);
p = p->next ;
}
printf("\n");
}
struct node * deletelast(struct node * p)
{
struct node *prev,*curr;
curr=p;
prev=NULL;
while(curr->next!=NULL)
{
prev=curr;
curr=curr->next;
}
prev->next=NULL;
free(curr);
return p;
}
struct node * deletefrst(struct node * p)
{
struct node *curr;
curr=p;
p=p->next;
free(curr);
return p;
}
struct node * deletenode(struct node * p , int x)
{
struct node *prev,*curr;

curr=p;
prev=NULL;
while((curr->data!=x)&&(curr->next!=NULL))
{ prev=curr;
curr=curr->next;}

if((curr->next==NULL)&&(curr->data!=x))
{ printf("the element x is not found");
prev->next=NULL;
free(curr);}
else {
prev->next=curr->next;
free(curr);}
return p;
}
int count(struct node * p)
{
struct node *curr;
int i=0;
curr=p;
while(curr!=NULL)
{
curr=curr->next;
i++;
}
return i;
}
struct node * insertfrst(struct node * p , int n)
{
struct node * temp;
temp=(struct node*)malloc(sizeof(struct node));
if(temp==NULL)
{
printf("no memory space");
exit(0);
}
else
{
temp->data=n;
temp->next=p;
p=temp;
}
return temp;
}
struct node *insertlast(struct node * p,int n)
{
struct node *temp,*curr;
temp=(struct node*)malloc(sizeof(struct node));
if(temp==NULL)
{
printf("no memory space");
exit(0);
}
curr=p;
while(curr->next!=NULL)
{
curr=curr->next;
}
temp->data=n;

temp->next=NULL;
curr->next=temp;
return p;
}

struct node * insertbefor(struct node * p,int n,int x)
{
struct node *temp,*prev,*curr;
temp=(struct node*)malloc(sizeof(struct node));
if(temp==NULL)
{

printf("no memory space");
exit(0);}
curr=p;
prev=NULL;
while((curr->data!=x)&&(curr->next!=NULL))
{ prev=curr;
curr=curr->next;}
if((curr->next==NULL)&&(curr->data!=x))
{ printf("the element x is not found");
temp->data=n;
temp->next=NULL;
curr->next=temp;}
else
{temp->data=n;
temp->next=curr;
prev->next=temp;}
return p;}
void main()
{
struct node * p;
int i;
p=create(20);
print(p);
for( i=1;i<=4;i++)
p=insertfrst(p,i);
print(p);
p=insertlast(p,34);
print(p);
p=insertbefor(p,77,34);
print(p); p=delete¬node(p,34);
print(p);
p=deletelast(p);
print(p);
p=deletefrst(p);
print(p);}

Is This Answer Correct ?    0 Yes 2 No

Post New Answer

More C Interview Questions

main() { int l=6; switch(l) { default:l=l+2; case 4:l=4; case 5:l++; break; } printf("%d",l); }

1 Answers  


Find MAXIMUM of three distinct integers using a single C statement

0 Answers  


24.what is a void pointer? 25.why arithmetic operation can’t be performed on a void pointer? 26.differentiate between const char *a; char *const a; and char const *a; 27.compare array with pointer? 28.what is a NULL pointer? 29.what does ‘segmentation violation’ mean? 30.what does ‘Bus Error’ mean? 31.Define function pointers? 32.How do you initialize function pointers? Give an example? 33.where can function pointers be used?

0 Answers  


Why structure is used in c?

0 Answers  


What header files do I need in order to define the standard library functions I use?

0 Answers  


Write a code to reverse string seperated by spaces i/p str=India is my country o/p str=aidnI si ym yrtnuoc After writing code, optimize the code

1 Answers  


How can my program discover the complete pathname to the executable from which it was invoked?

0 Answers  


What is operator promotion?

0 Answers  


What is Generic pointer? What is the purpose of Generic pointer? Where it is used?

3 Answers  


Write a program to reverse a linked list in c.

0 Answers   DELL, HAL,


Read two numbers from keyboard and find maximum of them?

1 Answers  


logic for x=y^n

1 Answers   Delphi,


Categories