The name of the array means the address of the first element, so 'arr==&arr[0]'
#include main() { int array[100], minimum, size, c, location = 1; printf("Enter the number of elements in array\n"); scanf("%d",&size); printf("Enter %d integers\n", size); for ( c = 0 ; c < size ; c++ ) scanf("%d", &array[c]); minimum = array[0]; for ( c = 1 ; c < size ; c++ ) { if ( array[c] < minimum ) { minimum = array[c]; location = c+1; } } printf("Minimum element is present at location number %d and it's value is %d.\n", location, minimum); return 0; }
in c simply add three lines in the begining of your program: int x; printf("enter the size of the array to be entered :"); scanf("%d",&x); after that use x as your maximum limit of array in your program. in c++ just replace above printf & scanf statements by cout<<"enter the size of the array to be entered :"; & cin>>x; respectively and do not use brackets.
#include<stdio.h> int main(){ int a[10],i,n,m,c=0; printf("Enter the size of an array: "); scanf("%d",&n); printf("Enter the elements of the array: "); for(i=0;i<=n-1;i++){ scanf("%d",&a[i]); } printf("Enter the number to be search: "); scanf("%d",&m); for(i=0;i<=n-1;i++){ if(a[i]==m){ c=1; break; } } if(c==0) printf("The number is not in the list"); else printf("The number is found"); return 0; }
main(){int n,a[i],s;s=0;printf("enter no of elements in array");scanf("%d",&n);printf("Enter elements in array");for(i=;i
Your best bet would probably be to iterate through the array using a for loop and compare each value to the current low and high values (which you would store in a local variable) for example: for each element in array { if current is less than lowest_value lowest_value = current else if current is greater than highest_value highest_value = current }
I guess you wanted to ask, why is it scanf ("%s", array)and not scanf ("%s", &array).Well, array is by definition a pointer to the first element: array = &array[0]
#include main() { int array[100], minimum, size, c, location = 1; printf("Enter the number of elements in array\n"); scanf("%d",&size); printf("Enter %d integers\n", size); for ( c = 0 ; c < size ; c++ ) scanf("%d", &array[c]); minimum = array[0]; for ( c = 1 ; c < size ; c++ ) { if ( array[c] < minimum ) { minimum = array[c]; location = c+1; } } printf("Minimum element is present at location number %d and it's value is %d.\n", location, minimum); return 0; }
in c simply add three lines in the begining of your program: int x; printf("enter the size of the array to be entered :"); scanf("%d",&x); after that use x as your maximum limit of array in your program. in c++ just replace above printf & scanf statements by cout<<"enter the size of the array to be entered :"; & cin>>x; respectively and do not use brackets.
#include<stdio.h> int main(){ int a[10],i,n,m,c=0; printf("Enter the size of an array: "); scanf("%d",&n); printf("Enter the elements of the array: "); for(i=0;i<=n-1;i++){ scanf("%d",&a[i]); } printf("Enter the number to be search: "); scanf("%d",&m); for(i=0;i<=n-1;i++){ if(a[i]==m){ c=1; break; } } if(c==0) printf("The number is not in the list"); else printf("The number is found"); return 0; }
main(){int n,a[i],s;s=0;printf("enter no of elements in array");scanf("%d",&n);printf("Enter elements in array");for(i=;i
Your best bet would probably be to iterate through the array using a for loop and compare each value to the current low and high values (which you would store in a local variable) for example: for each element in array { if current is less than lowest_value lowest_value = current else if current is greater than highest_value highest_value = current }
void main(){int a[10],i,n,m,c=0;clrscr();printf("Enter the size of an array");scanf("%d",&n);printf("\nEnter the elements of the array");for(i=0;i
#include "stdio.h" #define SIZE 100; void main() { int array[SIZE], i, size; printf("\nEnter the Size off Array :- "); scanf("%d", &size); printf("\nEnter the Elements of Array :- ")' for(i = 0; i < size; i++) scanf("%d", &array[i]; printf("\nThe Elements of entered Array :- "); for(i = 0; i < size; i++) printf("%7d", array[i]); }
for(i=0;i<10;i++) { scanf("%d",&a[i] ); }
#include<stdio.h> main() { int *ptr; int i,j,k=0,n,temp,n1,n2,c[20]; printf("\nEnter then no. os elememt of 1st array :"); scanf("%d",&n1); printf("\nEnter the element :\n"); ptr=(int *)malloc(n1* sizeof(int)); for(i=0;i<n1;i++,k++) { scanf("%d",ptr+i ); c[k]=*(ptr+i); } printf("\nEnter then no. os elememt of 2st array :"); scanf("%d",&n2); printf("\nEnter the element :\n"); ptr=(int *)malloc(n2* sizeof(int)); for(j=0;j<n2;j++,k++) { scanf("%d",ptr+j ); c[k]=*(ptr+j); } for(i=0;i<n1+n2;i++) { for(j=0;j<n1+n2;j++) { if(c[i]<c[j]) { temp=c[i]; c[i]=c[j]; c[j]=temp; } } } printf("\nAfter combined and sorted both array : \n"); for(i=0;i<n1+n2;i++) printf("Element [%d] = %d\n",i+1,c[i]); }
There is no scanf in Java. It is one of the keywords used in C Programming language
scanf ("%[^\n]s", sentence);