I'm a complete beginner coder. I've got an exercise and i don't seem to be able to finish it, whenever i try to get an answer with an if statement it doens't show it corretly and since I'm so new i can't figure it out, have been trying for over 4hrs.
#include <iostream>
using namespace std;
int main()
{
long int x, a, b, c, e, f;
long int d=10;
cout << "enter a number" << endl;
cin >> x;
c=x%10;
cout << c << endl;
if (c=0)
cout << "your number has 0's" << endl;
else{
while ((e!=0) && (f!=0)){
e=x/d;
f=e%10;
d=d*10;
}
cout << "5 " << f << "; " << e << endl;
if (f=0)
cout << "you have 0's" << endl;
else
cout << "you have no 0's" << endl;
}
return 0;
}
this is the code, the task is to find if a user input number has any 0's in it and so whenever you put in a number like 5480321 even tho it has an 0 and the cout<
Aucun commentaire:
Enregistrer un commentaire