c ++ 7-Dars.

jafar9442

Jafar9442

Posted on December 20, 2022

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

πŸ’– πŸ’ͺ πŸ™… 🚩
jafar9442
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.

Related

Veriables in C++
beginners Veriables in C++

March 4, 2024

Operators and Expression
beginners Operators and Expression

April 29, 2023