Pls... any one give me a simple program for finding the greatest of three numbers in C program... thanku.....
'C' Program help pls.....?
int a,b,c,max;
if(a%26gt;b)
{
max = a;
}
else max = b;
if(c%26gt;max)
max = c;
printf("maxm of three numbers is %d," max);
Reply:#include%26lt;stdio.h%26gt;
#include%26lt;conio.h%26gt;
void main()
{
clrscr();
int a,b,c;
scanf"%d",a,b,c;(i forget the syntax exactly,i dont know this syntax is right r wrong)
printf"%d a="a;
printf"%d b="b;
printf"%d c="c;
if(a%26gt;b)
{
if(a%26gt;c)
{
printf"A is greatest";
else
{
printf"C is greatest"
}
}
elseif(b%26gt;c)
{
Printf"C is greatest"
}
else
{ printf"b is greatest"
}
}
getch()
}
Reply:#include%26lt;stdio.h%26gt;
void main()
{ int a,b,c;
printf("\nEnter three nos");
scanf("%d%d%d",%26amp;a,%26amp;b,%26amp;c);
if(a%26gt;b %26amp;%26amp; a%26gt;c)
{
printf("\nLargest no %d",a);
}
else if(b%26gt;c)
{
printf("\nLargest no %d",b);
}
else
{
printf("\nLargest no %d",c);
}
}
Reply:Use "if...else..." statement
Reply:#include%26lt;stdio.h%26gt;
#include%26lt;conio.h%26gt;
void main()
{
int a,b,c;
clrscr();
printf("enter three values for a,b,andc:");
scanf("%d%d%d",%26amp;a,%26amp;b,%26amp;c);
if(a%26gt;b %26amp;%26amp; a%26gt;c)
printf("a is greatest");
else if(b%26gt;a %26amp;%26amp; b%26gt;c)
printf("b is greatest");
else
printf("c is greatest");
getch();
}
Reply:Programme to find the largest among three number in its simplest form :
#include%26lt;stdio.h%26gt;
main()
{
int a,b,c;
printf("Enter values :");
scanf("%d %d %d",%26amp;a,%26amp;b,%26amp;c);
if(a%26gt;b)
{
if(a%26gt;c)
{
printf("\nThe largest number is : %d", a);
}
else
{
printf("\nThe largest number is : %d", c);
}
}
else
{
if(b%26gt;c)
printf("\nThe largest number is : %d", b);
}
}
Reply:#include%26lt;stdio.h%26gt;
#include%26lt;conio.h%26gt;
main()
{
clrscr();
int a,b,c;
printf("Enter values :");
scanf("%d %d %d",%26amp;a,%26amp;b,%26amp;c);
if(a%26gt;b)
{
if(a%26gt;c)
{
printf("\nThe largest number is : %d", a);
}
else
{
printf("\nThe largest number is : %d", c);
}
}
else
{
if(b%26gt;c)
printf("\nThe largest number is : %d", b);
}
}
Reply:#include%26lt;stdio.h%26gt;
#include%26lt;conio.h%26gt;
#define max 3
void main()
{
int a[max], i, j;
clrscr();
for(i=0;i%26lt;max;i++)
{
printf("\n\tEnter the a[%d] number : ",i);
scanf("%d",%26amp;a[i]);
}
for(i=0;i%26lt;max;i++)
{
if(a[i]%26gt;a[i+1])
{
j=a[i];
a[i]=a[i+1];
a[i+1]=j;
}
if(i==max-1)
printf("\n\tThe greatest number is =%d",a[max-1]);
}
getch();
}
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment