answersLogoWhite

0

#inculde<iostream>

using namespace std;

int smallestIndex(int[],int) //function prototype

void main()

{

int arr[10]={2,5,6,9,3,7,1,15,12,10};

int position;

position=smallestIndex(arr,10);

cout<<"the smallestIndex

User Avatar

Wiki User

12y ago

What else can I help you with?

Continue Learning about Engineering

C code on Reversing integer array elements using temporary variable?

#include &lt;stdio.h&gt; int main() { int number, temp; printf("enter the number"); scanf("%d",&amp;number); printf("\n reverse of %d",number); while(number&gt;0) { temp=temp*10+number%10; number=number/10; } printf(" is %d",temp); }


What is the program of 2d array in gw basic?

In GW-BASIC, a 2D array can be declared using the DIM statement, specifying the number of rows and columns. For example, DIM A(5, 5) creates a 2D array named A with 6 rows and 6 columns (indexing starts from 0). You can access and manipulate elements using syntax like A(row, column). Here's a simple example: A(1, 1) = 10 assigns the value 10 to the element in the second row and second column of the array.


How do you calculate address of any element of array using formulae?

element_address = array_address + (element_index * element_size) Note that the array name refers to the start address of the array, element indices are always zero-based and element size is calculated at compile time using the sizeof() operator using the array type as the operand. int x[10]; int* p1 = x + (5 * sizeof(int)); // calculate address of 6th element int* p2 = &amp;x[5]; // return address of 6th element assert (p1==p2); // ensure both address are equal Note that the array suffix operator [] used by p2 is merely sugar-coating. Behind the scenes, the compiler will automatically generate code equivalent to that of the p1 calculation. As such, there is no advantage in using one over the other.


Can you help me with the C plus plus code of the program which has 10 index of array it adds 5 into every even elements of the array and then it subtracts 10 into the odd elements of the array?

int array[10] = {...}; for (int i = 0; i &lt; 10; ++i) { if (i % 2 == 0) array[i] += 5; else array[i] -= 10; }


How you can use array in c language?

An array is a contiguous block of memory containing one or more elements of the same type and size. Each element in the array is accessed as a zero-based offset from the start of the array or by using the index []. Examples: int a[10]; // allocates memory for 10 integers (e.g., 40 bytes for a 4 byte int). int x = a[5]; // accesses the 6th element (a[0] is the first element). int *p = a; // point to start of the array. p += 5; // advance pointer 5 * sizeof( int ) addresses. *p = 10; // access the 6th element and assign the value 10. int d * = new int[*p]; // dynamically allocate an array of 10 elements. delete [] d; // release dynamic array.

Related Questions

How do you store a number of integers entered by the user in an array with java?

use a loop(for or while) to get the input from the user then store each in the array using the Scanner class like this import java.util.Scanner;//before class declaration int[] Array = new int[10]; //just an example gets 10 ints from user Scanner input = new Scanner(System.in); then something like this for(int i = 0; i &lt; 10;i++) { System.out.println("enter number:"); Array[i]= input.nextInt(); }


How do you create a loop using PHP?

There are a number of different ways to loop using PHP. They're as follows:ForForeachWhileDo-whileBelow are some examples of how each of these types of loop work.ForForeachWhileDo-while


C code on Reversing integer array elements using temporary variable?

#include &lt;stdio.h&gt; int main() { int number, temp; printf("enter the number"); scanf("%d",&amp;number); printf("\n reverse of %d",number); while(number&gt;0) { temp=temp*10+number%10; number=number/10; } printf(" is %d",temp); }


How do you calculate address of any element of array using formulae?

element_address = array_address + (element_index * element_size) Note that the array name refers to the start address of the array, element indices are always zero-based and element size is calculated at compile time using the sizeof() operator using the array type as the operand. int x[10]; int* p1 = x + (5 * sizeof(int)); // calculate address of 6th element int* p2 = &amp;x[5]; // return address of 6th element assert (p1==p2); // ensure both address are equal Note that the array suffix operator [] used by p2 is merely sugar-coating. Behind the scenes, the compiler will automatically generate code equivalent to that of the p1 calculation. As such, there is no advantage in using one over the other.


Can you help me with the C plus plus code of the program which has 10 index of array it adds 5 into every even elements of the array and then it subtracts 10 into the odd elements of the array?

int array[10] = {...}; for (int i = 0; i &lt; 10; ++i) { if (i % 2 == 0) array[i] += 5; else array[i] -= 10; }


How you can use array in c language?

An array is a contiguous block of memory containing one or more elements of the same type and size. Each element in the array is accessed as a zero-based offset from the start of the array or by using the index []. Examples: int a[10]; // allocates memory for 10 integers (e.g., 40 bytes for a 4 byte int). int x = a[5]; // accesses the 6th element (a[0] is the first element). int *p = a; // point to start of the array. p += 5; // advance pointer 5 * sizeof( int ) addresses. *p = 10; // access the 6th element and assign the value 10. int d * = new int[*p]; // dynamically allocate an array of 10 elements. delete [] d; // release dynamic array.


How do you make a program that counts how many times each digit occured in the integer?

To count the number of times a digit occurs in an integer, start by initializing an array of ten counts of digits, such as int digits[10];Then, in a loop while the number is non zero, increment the element in the digits array that corresponds to the units digit, and then divide the number by ten, such as digits[number%10]++ and number/=10;int digits[10];int i;int number = some number;for (i=0; i


What numbers 2 to 10 make only one array?

The numbers from 2 to 10 that can form only one unique array (or arrangement) are 2, 3, 4, 5, 6, 7, 8, 9, and 10. This is because each of these numbers can be represented by a single array consisting of just that number itself. For instance, the number 2 can only be represented as [2], and similarly for the other numbers. In contrast, the number 1 can be arranged as a single element array or combined with other elements to create different arrays.


How do you access and store the elements of array?

#include&lt;stdio.h&gt; #include&lt;conio.h&gt; int main(void) { int a[10],i;//array declaration clrscr(); printf("\n enter the elements of array"); for(i=0;i&lt;10;i++) scanf("%d",&amp;a[i]); printf("\n the elements you enter into the array"); for(i=0;i&lt;10;i++) printf("%5d",a[i]); getch(); return 0; }


What is the container object that holds a fixed number of values of single type?

There are multiple answers to this question, but the most basic one common to both Java and C is the array. An array is a simple structure that you initialize to a certain size and fill with data. Think of an array as a sort of list, where each element in the list is numbered starting from zero up to the list size minus one (or the array is zero-based, as it's also called). In Java: // 10 is the number of elements the array can hold int[] myIntArray = new int[10]; myIntArray[0] = 2; // The first element in the array myIntArray[9] = 4; // The last element in the array Referencing myIntArray[10] or higher will cause a runtime error in Java, which may stop your program. In C: // 10 is the number of elements the array can hold int myIntArray[10]; myIntArray[0] = 2; // The first element in the array myIntArray[9] = 4; // The last element in the array Referencing myIntArray[10] or higher results in a buffer overflow in C (and C++). Note that in C, this won't throw errors like they do in Java, and this can and very likely will cause your program to have random bugs and possibly even crash from a segmentation fault, so be a bit more careful about using arrays in C.


How do you calculate accrued interest at 10 percent per annum?

calculate 10% of number ($2950.00 x 10% = 295.00) then divide it by 12.


Write a c user defined functions to put n real number in a single dimenssion array compute their meanvariancestandarad deviation using these functions write a c program?

#include&lt;stdio.h&gt; #include&lt;conio.h&gt; int arr(int a[]); void main() { int a[10],i; clrscr(); printf("Enter the value for array") for(i=0;i&lt;10;i++) { scanf("%d",&amp;a[i]); } arr(a); getch(); } int arr(int a[10]) { int i; printf("Elements of array\n"); for(i=0;i&lt;10;i++) { printf("\n%d",a[i]); } return 0; }