C Program to calculate Minimum of three numbers

Description:

This program accepts Three integers as input and calculates the Minimum number.

Program :

  1. #include<stdio.h>
  2. int main()
  3. {
  4.    int a,b,c,min;
  5.    printf(“Enter Three numbers : “);
  6.    scanf(“%d%d%d”,&a,&b,&c);
  7.    if( (a<b) && (a<c) )
  8.    {
  9.       min = a;
  10.    }
  11.    else if(b<c)
  12.    {
  13.       min = b;
  14.    }
  15.    else
  16.    {
  17.       min = c;
  18.    }
  19.    printf(“Min of %d, %d and %d is : %dn,a,b,c,min);
  20.    return 0;
  21. }

Output:

Related C Programs:

Venkatesh

Hi Guys, I am Venkatesh. I am a programmer and an Open Source enthusiast. I write about programming and technology on this blog.

You may also like...

2 Responses

  1. Binary search [int array]

    Binary search [int array]

    #include

    #define TRUE 0
    #define FALSE 1

    int main(void) {
    int array[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
    int left = 0;
    int right = 10;
    int middle = 0;
    int number = 0;
    int bsearch = FALSE;
    int i = 0;

    printf("ARRAY: ");
    for(i = 1; i <= 10; i++)
    printf("[%d] ", i);

    printf("nSearch for Number: ");
    scanf("%d", &number);

    while(bsearch == FALSE && left <= right) {
    middle = (left + right) / 2;

    if(number == array[middle]) {
    bsearch = TRUE;
    printf("** Number Found **n");
    } else {
    if(number < array[middle]) right = middle – 1;
    if(number > array[middle]) left = middle + 1;
    }
    }

    if(bsearch == FALSE)
    printf("– Number Not found –n");

    return 0;
    }

  1. […] C Program to Calculate the Minimum of Three Numbers […]

Leave a Reply