#include<stdio.h>
#include<conio.h>
main()
{
int num, n,sum=0,i=0;
printf("enter the number of elements to be added ");
scanf("%d",&n);
printf("enter %d numbers",n);
while(i<n)
{
scanf("%d",&num);
sum=sum+num;
i=i+1;
}
printf("the sum of %d numbers is %d",n,sum);
getch();
}
#include <stdio.h>
char input[1000];
float temp; /* temporary storage for numbers entered */
int num_count; /* number to divide total by */
float total; /* Total of numbers entered */
float average; /* 'total' divided by 'num_count' */
int main() {
/* Tell user what program does */
printf("I will find the average of however many numbers you enter.\n");
printf("Enter number now (00 to quit): ");
/* Accept first input from user */
fgets(input, sizeof(input), stdin);
temp = atof(input);
/* Initalize Variables */
num_count = 0;
total = 0.0;
average = 0.0;
while ( temp != 00.0 ) {
++num_count; /* increases with each number entered */
total += temp; /* adds all numbers entered to total */
printf("Enter next number now (00 to quit): ");
fgets(input, sizeof(input), stdin);
temp = atof(input);
}
average = ( total / num_count );
printf("You entered %d numbers. The average of those numbers is %f.\n", num_count, average);
return 0;
}
#include
#include
int i;
void main()
{
int sum(int b[],int n);
int sum_num,n,a[20];
clrscr();
printf("\nEnter the Items of an Array:");
scanf("%d",&n);
printf("Enter numbers into Array:");
for(i=0;i
sum_num=sum(a,n);
printf("The Sum of Array Numbers is = %d",sum_num);
getch();
}
int sum(int b[],int n)
{
int s=0;
for(i=0;i
s+=b[i];
}
return s;
}
output:
Enter the Items of an Array:5
Enter numbers into Array:
10
45
20
23
96
The Sum of Array Numbers is = 194
#include <iostream>
#include <vector>
using std::cout;
using std::cin;
using std::endl;
using std::vector;
int main()
{
int counter = 1;
cout << "Enter " << counter
<< " number (when you finish press any letter)";
vector<double> arrayOfData;
double tempVar = 0.0;
while (cin >> tempVar)
{
arrayOfData.push_back(tempVar);
++counter;
cout << "Enter " << conter << " number";
}
double sumOfElements = 0.0;
for (size_t i = 0; i < arrayOfData.size(); i++)
{
sumOfNumbers += arrayOfData.at(i);
}
cout << "\nAverage is: " << (sumOfNumbers/arrayOfData.size());
system("PAUSE");
return 0;
}
#include<stdio.h>
#include<conio.h>
main()
{
int marks[100];
int i,n,sum,average;
printf("enter the number of students");
scanf("%d",&n);
printf("enter %d student's marks",n);
sum=0;
for(i=0;i<n;i++)
{
scanf("%d",&marks[i]);
sum=sum+marks[i];
}
average=sum/n;
printf("the sum of the marks of %d studens is %d\n",n,sum);
printf("the average of %d students is %d\n",n,average);
getch();
}
A single dimensional array is an array of items. A two-dimensional array is an array of arrays of items.
A two dimensional array is a one-dimensional array of one-dimensional arrays. That is, just as we can have an array of integers, we can also have an array of integer arrays. This idea can be extended such that we can have an array of two-dimensional arrays (a three-dimensional array), and so on. We typically use a two-dimensional array to represent a table of rows and columns, where each row is a one-dimensional array.
The dimensions are 3 x 6. Also, since there are two numbers, you might say it is a 2-dimensional array.
one dementional array and two dementional array
find even number in array
A one dimensional array is an array of objects that goes in one "direction". Any array with only one [] is a one dimensional array. For example: int numbers[6]; is a one dimensional array. int numbers[6][3]; is a two dimensional array.Graphical terms:One dimensional array[4]:14 - 75 - 8164 - 234Two dimensional array[2][3]:47 - 178108 - 8517 - 128It didn't come out quite how I wanted it...
An array is a set of numbers that form some sort of regular arrangement. A linear array is a 1-dimensional array consisting of a row or a column of a set of numbers. A 2-dimensional array is a rectangular arrangement of numbers. And there are arrays with higher dimensions. The elements of an array need not be numbers: they could be variables, functions or expressions. In other words, it's a picture to describe a multiplication problem.
A single dimensional array is an array of items. A two-dimensional array is an array of arrays of items.
A One dimensional array is one in which a set of values are present in it. Ex: int[] myArray = new int[4]; The above statement creates a one dimensional array that can hold 4 values.
A program which is used to count the number of numbers in an array using a 8085 microprocessor is known as a assembly language program.
A one dimensional array is a scalar value repeated one or more times.A two dimensional array is an array of one dimensional arrays.A three dimensional array is an array of two dimensional arrays, and so forth.The one dimensional array is like a list of things, where the two dimensional array is like an array of things. (Think one row of a spreadsheet versus the whole spreadsheet.)[addendum]Every level of array depth is also a level of pointer depth. For example: A 3 dimensional int array is an int***. So a one dimensional int array is an int*, and a two dimensional int array is an int**. This is only important if you are doing pointer work, but it can become very important.
A two-dimensional array is the simplest multi-dimensional array and is implemented as a one-dimensional array where every element is itself a one-dimensional array. We can imagine a two-dimensional array as being a table of rows and columns where every row is an array in its own right. A three-dimensional array is simply a one-dimensional array of two-dimensional arrays, which can be imagined as being an array of tables. Extending the concept, a four-dimensional array is a table of tables. Multi-dimensional arrays may be jagged. That is, a two-dimensional array may have rows of unequal length. Unlike regular arrays, jagged arrays cannot be allocated in contiguous memory. Instead, we use the outer array (the first dimension) to store pointers to the inner arrays. An array of strings (character arrays) is an example of a two-dimensional jagged array.
array type
A two dimensional array is a one-dimensional array of one-dimensional arrays. That is, just as we can have an array of integers, we can also have an array of integer arrays. This idea can be extended such that we can have an array of two-dimensional arrays (a three-dimensional array), and so on. We typically use a two-dimensional array to represent a table of rows and columns, where each row is a one-dimensional array.
The dimensions are 3 x 6. Also, since there are two numbers, you might say it is a 2-dimensional array.
A One dimensional array is one in which a set of values are present in it. Ex: int[] myArray = new int[4]; The above statement creates a one dimensional array that can hold 4 values.
one dementional array and two dementional array