Write a program which calculate sum of several number and input it into an array. Then, the sum of all the number in the array is calculated.
Answers were Sorted based on User's Feedback
Answer / devi
#include<stdio.h>
#include<conio.h>
void main()
{
int a[200],i,n;
float sum=0,avg;
clrscr();
printf("Enter the n values");
scanf("%d",&n);
for(i=0;i<n;i++)
{
sum=sum+a[i];
}
avg=sum/n;
printf("Sum of %d array values is:%f",n,avg);
getch();
}
Is This Answer Correct ? | 7 Yes | 5 No |
Answer / pradeepnair
#include<stdio.h>
#include<conio.h>
void main()
{
int val1;
int val2;
int size=0;
int a,b[100];
int i,n,j,k=1;
int sum=0;
int sum1=0;
printf("enter the no of values to be added");
scanf("%d",&val1);
for(i=0;i<val1;i++)
{
scanf("%d",&a);
sum=sum+a;
}
System.out.println("the sum is"+sum);
while(sum>0)
{
val2 = sum%10;
sum=sum/10;
b[k]=val2;
size=size+1;
k--;
}
printf("the values in array are");
for(i=0;i<size;i++)
{
printf("/n",b[i]);
}
for(j=0;j<size;j++)
{
sum1=sum1+b[j];
}
printf("the sum of values an array is $d",sum1)
getch();
}
Is This Answer Correct ? | 1 Yes | 0 No |
write a program that reads lines(using getline), converts each line to an integer using atoi, and computes the average of all the numbers read. also compute the standard deviation.
How to print India by nested loop? I IN IND INDI INDIA
what is c programing
Write an implementation of “float stringToFloat(char *str).” The code should be simple, and not require more than the basic operators (if, for, math operators, etc.). • Assumptions • Don’t worry about overflow or underflow • Stop at the 1st invalid character and return the number you have converted till then, if the 1st character is invalid return 0 • Don’t worry about exponential (e.g. 1e10), instead you should treat ‘e’ as an invalid character • Write it like real code, e.g. do error checking • Go though the string only once • Examples • “1.23” should return 1.23 • “1a” should return 1 • “a”should return 0
. Consider the following program main() { int a[5]={1,3,6,7,0}; int *b; b=&a[2]; } The value of b[-1] is (A) 1 (B) 3 (C) -6 (D) none
Was 2000 a leap year?
Explain bitwise shift operators?
6)swap(int x,y) { int temp; temp=x; x=y; y=temp; } main() { int x=2;y=3; swap(x,y); } after calling swap ,what are yhe values x&y?
what is the stackpointer
Is multithreading possible in c?
Just came across this question, felt worth sharing, so here it is I want you to make a C/C++ program that for any positive integer n will print all the positive integers from 1 up to it and then back again! Let's say n=5 I want the program to print: 1 2 3 4 5 4 3 2 1. Too easy you say? Okay then... You can ONLY USE: 1 for loop 1 printf/cout statement 2 integers( i and n) and as many operations you want. NO if statements, NO ternary operators, NO tables, NO pointers, NO functions!
What is sizeof array?