C Program to calculate Minimum of three numbers
Description:
This program accepts Three integers as input and calculates the Minimum number.
Program :
-
#include<stdio.h>
-
int main()
-
{
-
int a,b,c,min;
-
printf(“Enter Three numbers : “);
-
scanf(“%d%d%d”,&a,&b,&c);
-
if( (a<b) && (a<c) )
-
{
-
min = a;
-
}
-
else if(b<c)
-
{
-
min = b;
-
}
-
else
-
{
-
min = c;
-
}
-
printf(“Min of %d, %d and %d is : %dn“,a,b,c,min);
-
return 0;
-
}
Output:
Related C Programs:
- Program to calculate Maximum of three numbers.
- What is Prime Number and C program to Check given number is Prime or Not
- Check given Number is Prime or not Using Square Root(sqrt) Function.(Efficient way)
- C Program to generate prime numbers between two numbers
- C Program to generate first N prime numbers.
- C program to Calculate percentage of student.
- C Program to check given year is the leap or not.
- C Program to convert Temparatuere.
- C program to understand type conversation.
- Finding Largest of two numbers using the conditional operator in C.
- C program to calculate the simple Interest,
- C program to understand Size of Operator.
- 200+ C Programs.
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;
}