1>How to Write a C- program to find greatest between two number. java 8 download
![]() |
c-program |
#include<stdio.h>
#include<conio.h>
Void main()
{
int a,
b;
clrscr();
printf(“Enter the value of a and b”);
scanf(“%d%d”,&a,&b);
if(a>b)
Printf(“Greatest number is =%d”,a);
else
printf(“Greatest number is=%d”,b);
getch();
}
Input= Enter the value of a, and
b
2
5
Output= Greatest
number is=5
2>How to Write a C- program to find out greatest from 3- numbers.
#include<stdio.h>
#include<conio.h>
Void main()
{
int a, b,c,max;
clrscr();
printf(“Enter the value of a, b and c”);
scanf(“%d%d%d”,&a,&b,&c);
if(a>b)
max=a;
else
max=b;
if(max>c)
printf(“Greatest number is=%d”,max);
else
printf(“Greatest number is=%d”,c);
getch();
}
Input= Enter the value of a, b and c
2
3
4
3>How to Write a C- program to find out greatest from n- numbers.
#include<stdio.h>
#include<conio.h>
Void main()
{
int a,n,i,max=0;
Clrscr();
Printf(“Enter the number in which you want to find greatest \n”);
Scanf (“%d”,&n);
Printf(“Enter the numbers \n” );
For(i=1; i<=n; i++)
{
scanf(“%d”,&a);
If(a>max)
max=a;
else
max=max;
}
Printf(“Greatest number is =%d”,max);
getch();
}
Input= Enter the
number in which you want to find
greatest .
4
Enter the numbers
1
3
25
4
Output= Greatest number is = 25
![]() |
output |
0 Comments