#include <conio.h>
#include <stdio.h>
#include <iostream.h>
void main()
{
float x,y,z;
cout<<"Ievadi x vertibu: "; cin>>x;
cout<<"Ievadi y vertibu: "; cin>>y;
cout<<"Ievadi z vertibu: "; cin>>z;
if (x>y,x>z){
cout<<" Lielakais skaitlis ir "<<x;
}
if (y>x,y>z){
cout<<" Lielakais skaitlis ir "<<y;
}
if (z>x,z>y){
cout<<" Lielakais skaitlis ir "<<z;
}
getch();
}
Problem is , when i enter numbers like 4,2,1 (x,y,z) it shows that 4 is the biggest, but also it shows that 2 is the biggest, because it's bigger than 1. Sorry for my english guys, im totally new to C++, started IT programme few days ago. Thanks for your help!
In your if clauses, you use the comma operator. That will just return the last evaluation. You really want to use the "and" operator (&&). So your first check will be if ((x > y) && (x > z)) (I really like the extra parentheses to be explicit about the order of evaluation.)
By the way, in future posts, please use code tags. click on the "<>" button in the Format options and paste your code between the tags that are generated. This makes it easier for the reader to understand and make references to your code.