DEV Community

etibor2006
etibor2006

Posted on • Updated on

C ++

Biz bugun sonlarini kasr korinishida ishlashni o'rganamiz.

float eni,boyi;
  cin>> eni >> boyi;
  cout << setprecision(2)<< fixed << eni * boyi;

  return 0;
}
Enter fullscreen mode Exit fullscreen mode

Bu kodda esa to'rtburchakni boyi bilan enini topishini o'rganamiz.

 int eni,boyi;
  cout<<"to'rtburchakning enin kiriting:";
  cin>>eni;
  cout<<"to'rtburchakni boyini kiriting:";
  cin>>boyi;
  cout<<"tortbuchakni yuzi:" << eni * boyi;



  return 0;
}
Enter fullscreen mode Exit fullscreen mode

Bu kodda esa 2 xonali soni yonama-yon yozishni organamiz.

 int kun,oy;

  cin>>kun >> oy;
  cout<<"Birthday is ";
  cout<< setw(2) << setfill('0')<< kun <<'-';
  cout<< setw(2) << setfill('0') << oy <<'.';


  return 0;
}
Enter fullscreen mode Exit fullscreen mode
cout << "1!=" << 1*1 <<endl;
  cout <<"2!=" << 2*1 << endl;
  cout <<"3!=" << 3*2 << endl;
  cout << "4!=" << 4*6 << endl;
  cout << "5!=" << 5*24;


  return 0;
}
Enter fullscreen mode Exit fullscreen mode

Tekis oldidan sonin qo'yishni o'rganamiz.

cout << "1!=" << 1*1 <<endl;
  cout <<"2!=" << 2*1 << endl;
  cout <<"3!=" << 3*2 << endl;
  cout << "4!=" << 4*6 << endl;
  cout << "5!=" << 5*24;


  return 0;
}
Enter fullscreen mode Exit fullscreen mode

Dastlabki 10 taFibonaccisonlarini chop etishini o'rganamiz.

#include <iostream>
using namespace std;
int main (){
int a = 0;
int b = 1;
int c = a + b;
cout << a <<  ' '  << b << ' ' << c << ' ';
a = b;
b = c;
c = a + b;
cout << c << ' ';
a = b;
b = c;
c = a + b;
 cout << c << ' ';
a =b;
  b = c;
  c = a + b;
   cout << c << ' ';
  a =b;
  b = c;
  c = a + b;
    cout << c << ' ';
  a =b;
  b = c;
  c = a + b;
    cout << c << ' ';
  a =b;
  b = c;
  c = a + b;
   cout << c << ' ';
  a =b;
  b = c;
  c = a + b;

  cout << c << ' ';

return 0;
  }
Enter fullscreen mode Exit fullscreen mode

@dawroun

Top comments (0)