DEV Community

Jafar9442
Jafar9442

Posted on

c ++ 7-Dars.

Ushbu kodda 5ta xonali sondan 3xonasini olishni o'rganamiz.

#include <iostream>
#include <iomanip>
using namespace std;
int main() { 
int son;
  cin >> son; 
cout << son /100 % 10; // 12345 dan 3ni yani 3-chi sini olishni o'rganamiz
return 0;
}

Enter fullscreen mode Exit fullscreen mode

Ushbu kodda sondan keyin ! belgisi chiqarish o'rganamiz.

#include <iostream>
#include <iomanip>
using namespace std;
int main() {
int son;
cin >> son;
cout << son / 10000 << '!';
cout << son / 1000 % 10 << '!';
cout << son / 100 % 10 << '!';
cout << son / 10 % 10 << '!';
cout << son / 1 % 10;
  // ushbu kodda sondan keyin ! belgi chiqarish o'rganamiz.
return 0;
}
Enter fullscreen mode Exit fullscreen mode

Ushbu kodda bolub /, va foiz %, javobi chiqarishni o'rganamiz.

#include <iostream>
#include <iomanip>
using namespace std;
int main() {

cout << 3 / 10 << endl; // javobi 0
cout << 3 % 10 << endl; // javobi 3

return 0;
}
Enter fullscreen mode Exit fullscreen mode

@dawroun

Top comments (0)