This forum is now read-only. Please use our new forums! Go to forums
banner
Close banner
language c
in my language c class i tried to do the next two problems;
- Get three numbers by the user and print the bigger one.
- Get three numbers by the user and print the bigger number, medium and the smaller.
i tried this buy didn’t word y dev program
#include <stdio.h>
#include <conio.h>
int main(){
int a,b,c;
printf("ingresa primer valor");
scanf("%f", &a);
printf("segundo valor");
scanf("%f", &b);
printf("tercer valor");
scanf("%f", &c);
if (a>b && a>c){
printf("este es el mayor: %f", a);
}
if(b>a && b>c){
printf("mayor is:%f", b);
}
d
if (c>a && c>b){
printf("mayor is:%f", c);
}
return 0;
}
Edit: made code look like code by haxor789
Answer 540d68528c1ccc061e00ae1e
0 votes
a,b and c are int so the corrsponding format string would be %d or %i not %f: http://en.wikipedia.org/wiki/Printf_format_string#Type
Algorithm to get the biggest number. Take two of the numbers e.g. a and b compare them and compare the bigger one to the last. The bigger one of the second comparision is the biggest: e.g.
int max = a;
if(b > a)
max = b;
//else stays the same so not needed.
if(max < c)
max = c;
//else stays the same so not needed.
printf("mayor is:%i",max);
And for the second task you just need to compare the remaining two numbers.
Popular free courses
- Free Course
Learn SQL
In this SQL course, you'll learn how to manage large datasets and analyze real data using the standard data management language.Beginner friendly,4 LessonsLanguage Fluency - Free Course
Learn JavaScript
Learn how to use JavaScript — a powerful and flexible programming language for adding website interactivity.Beginner friendly,11 LessonsLanguage Fluency - Free Course
Learn HTML
Start at the beginning by learning HTML basics — an important foundation for building and editing web pages.Beginner friendly,6 LessonsLanguage Fluency