This is a discussion on Greatest of Three Numbers Without Using Two Variable within the C and C++ Programming forums, part of the Software Development category; The following program use only two variable for greatest of three number Code: #include<stdio.h> void main() { ...
| |||||||
| Register | FAQ | Members List | Calendar | Mark Forums Read |
| |||
| The following program use only two variable for greatest of three number Code: #include<stdio.h>
void main()
{
int a,b;
scanf("%d",&a);
scanf("%d",&b);
if(a>b)
b=a;
scanf("%d",&a);
if(a>b)
printf("Big value=%d",a);
else
printf("Big value=%d",b);
} OUTPUT Code: 10 20 30 Big value=30
__________________ -Murali.. Last edited by Murali : 10-29-2007 at 10:35 PM. |
| Sponsored Links |
| |||
| The following program use Three variable for Greatest of 'N' numbers Code: #include<stdio.h>
void main()
{
int a,b,n;
printf("Enter the N value=");
scanf("%d",&n);
printf("Enter the irst value=");
scanf("%d",&b);
while (n>1)
{
printf("Enter the Next value=");
scanf("%d",&a);
if(a>b)
b=a;
n=n-1;
}
if(a>b)
printf("Big value=%d",a);
else
printf("Big value=%d",b);
} Code: Enter the N value=5 Enter the First Value=40 Enter the Next value=38 Enter the Next value=19 Enter the Next value=42 Enter the Next value=37 Big Value=42
__________________ -Murali.. |
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Validating Numbers | ragavraj | PHP Programming | 1 | 11-07-2007 07:12 AM |
| Greatest of Three Numbers Without Using Relational Operator? | velhari | C and C++ Programming | 4 | 10-25-2007 03:10 AM |
| Static Global Variable and Static Local Variable | vigneshgets | C and C++ Programming | 1 | 05-30-2007 11:50 AM |
| What is your greatest fear? | KHyuga | The Lounge | 11 | 03-14-2007 10:53 AM |
| Your Greatest Regret? | KHyuga | The Lounge | 0 | 02-23-2007 09:38 AM |