Posts

Showing posts from November, 2015

open blog

http://adf.ly/1SWOs6

Linear search in c

Linear search in c  #include <stdio.h> int main() {    int array[100], search, c, n;    printf("Enter the number of elements in array\n");    scanf("%d",&n);    printf("Enter %d integer(s)\n", n);    for (c = 0; c < n; c++)       scanf("%d", &array[c]);    printf("Enter the number to search\n");    scanf("%d", &search);    for (c = 0; c < n; c++)    {       if (array[c] == search)     /* if required element found */       {          printf("%d is present at location %d.\n", search, c+1);          break;       }    }    if (c == n)       printf("%d is not present in array.\n", search);    r...

C program to find minimum element in array

C program to find minimum element in array : #include <stdio.h> int 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 %d and it's value is %d.\n", locatio...