$arr=array(2,5,4,6,7,8,1); for($i=0;$i<count($arr);$i++) { for($j=$i;$j<count($arr);$j++) { if($arr[$i] > $arr[$j]) { $temp=$arr[$i]; $arr[$i]=$arr[$j]; $arr[$j]=$temp; } } }
I did this as an answre to some common js questions , the question wasWrite a function which will return you first two times 1, then 2, then 3, then 5 and so on (Fibonacci numbers). Don't use any global variables.var fibonacci = (function () {var arr = [0, 1];return function () {var num = arr[arr.length - 1],len = arr.length;arr.push(arr[len - 1] + arr[len - 2]);return num;};}());//testvar i;for (i = 0; i < 10; i++) {console.log(fibonacci());}//1,1,2,3,5,8,13,21,34,55
There are many ways you can make a flowchart that will print and display a name 10 times. One example, will make you work with array, but you would input arr[1] for Sunday and arr[7] for Saturday.
#include<stdio.h> #include<conio.h> void main() { int a[10],count_even=0,count_odd=0,neg=0,i; printf(" Enter the value in Array \n"); for(i=0;i<10;i++) scanf("%d", &a[i]); /* Calculating number of odd and even integer's */ for(i=0;i<10;i++) { if((a[i]%2 ==0)) count_even++; if((a[i]%2==1)) count_odd++; if(a[i]<0) neg++; } /* display the number of odd and even integer's */ printf(" Total number of even integer are %d\n ",count_even); printf("Total number of odd integer are %d\n", count_odd); printf(" Total negative integer are %d", neg); getch(); }
Density is calculated by dividing the mass and volume of an object.
If the calculated ARR is greater that the predetermined ARR then accept the project. otherwise reject the project
$arr=array(2,5,4,6,7,8,1); for($i=0;$i<count($arr);$i++) { for($j=$i;$j<count($arr);$j++) { if($arr[$i] > $arr[$j]) { $temp=$arr[$i]; $arr[$i]=$arr[$j]; $arr[$j]=$temp; } } }
No arr refers to address of array &arr refers address of address of array but compiler treats arr and & arr, so even you place arr and & arr no error only warnings will be displayed.
Yes, 'ARR' and 'ARR' are the same for char20. Whatever it means.
for example:int arr[3];arr[0] = 1; /* ok */arr[1] = 2; /* ok */arr[2] = 0; /* ok */arr[3] = -1; /* wrong */arr[-1] = -3; /* wrong */
ways of getting 14 1,1,6,6 6 arrangements (1,6,1,6; 1,6,6,1; 1,1,6,6; 6,6,1,1; 6,1,6,1; 6,1,1,6) 1,2,5,6 24 arr. 1,3,4,6 24 arr. 1,3,5,5 12 arr. 1,4,4,5 12 arr. 2,2,4,6 12 arr. 2,2,5,5 6 arr. 2,3,3,6 12 arr. 2,3,4,5 24 arr. 2,4,4,4 4 arr. 3,3,3,5 4 arr. 3,3,4,4 6 arr. Total: 146 146*(1/6)4 = 0.1127... so slightly over 1/9
9, the elements are: arr[0], arr[1], ... arr[9]
ARR = Average Room Revenue
formula for arr- total room revenue ARR= ------------------------------ total occupied room
Implement these methods: public static int smallest(int[] arr) { int small = arr[0]; for(int i = 1; i < arr.size(); i++) if(arr[i] < small) small = arr[i]; return small; } public static int largest(int[] arr) { int large = arr[0]; for(int i = 1; i < arr.size(); i++) if(arr[i] > large) large = arr[i]; return large; }
# include<stdio.h> # include<conio.h> void main() { int arr[10]; int i,j,temp; clrscr(); for(i=0;i<10;i++) scanf("%d",&arr[i]); for(i=0;i<9;i++) { for(j=i+1;j<10;j++) { if(arr[i]<arr[j]) { temp=arr[i]; arr[i]=arr[j]; arr[j]=temp; } } } printf("\nSorted array elements :\n"); for(i=0;i<10;i++) printf("%d ",arr[i]) ; getch(); }
the address of variable (pointer) that contains array