0

How can I do program in C to compare between two numbers "double type"

The user should enter two number and I should answer , which one is smaller the the second

15th May 2018, 9:14 AM
Amer Alhafid
3 Respuestas
0
if what you really meant is C and not C++ then here is an example #include<stdio> double x, y; void main() { printf("enter first number :" ) ; scanf("%lf", & x) ; printf("enter second number :" ); scanf("%lf", & y) ; printf("\n"); if(x >y) { printf("the first number is greater %lf > %lf " x, y) ; } else if ( x<y) { printf("the second number is greater %lf > %lf" y, x) ; } else { printf("the first number = the second") } }
15th May 2018, 11:34 AM
Bahhaⵣ
Bahhaⵣ - avatar
0
hi, try this code:- for c programming ------------------------------------------ #include <iostream> #include <conio.h> void main() { double a,b; printf("1st number: "); scanf("%lf", &a); printf("2nd number: "); scanf("%lf", &b); printf("\n"); printf("result: "); if (a>b){ printf("a is greater than b"); } if (a==b){ printf("a equals b"); } if(a<b){ printf("a is smaller than b"); } getch(); } // #C_programming # Codding
15th May 2018, 11:44 AM
Rajeeb
0
thanks guys i solved it 😘😘
29th May 2018, 1:57 PM
Amer Alhafid