c ++ 7-Dars.
Jafar9442
Posted on December 20, 2022
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;
}
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;
}
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;
}
π πͺ π
π©
Jafar9442
Posted on December 20, 2022
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.