Sonni ekranga chiqarish
printf ("%d", c);
Bu yerga butun son kiritiladi
Bu sonni c yacheyka o’ziga oladi
printf (“Natija: %d", c);
printf ("%d+%d=%d", a, b, c );
Kiritiluvchi formati
Qiymatlar ro’yxati
a, b, c
printf ("%d+%d=%d", a, b, a+b );
Arifmetik amal
Butun sonni kiritish
int x = 1234;
printf ("%d", x);
1234
printf ("%9d", x);
Minimal son joylashishi
1234
Jami 9 ta joy
yoki "%i"
yoki "%9i"
Haqiqiy sonni chiqarish
float x = 123.4567;
printf ("%f", x);
123.456700
printf ("%9.3f", x);
Minimal son joylashuvi, 6 raqam kasr qismida
123.457
Jami 9 ta joy, 3 raqam kasr qismida
printf ("%e", x);
1.234560e+02
Standart ko’rinish: 1,23456·102
printf ("%10.2e", x);
1.23e+02
Jami 10 ta joy, 2 ta son kasr qismining mantissasida
To’liq yechim
#include
#include
void main()
{
int a, b, c;
clrscr();
printf(“Ikkita butun sonni kiriting\n");
scanf("%d%d", &a, &b);
c = a + b;
printf("%d+%d=%d", a, b, c);
getch();
}
NATIJA:
Ikkita butun sonni kiriting
25 30
25+30=55
Bu kompyuter chiqaradi
Buni foydalanuvchi kiritadi
Buni kompyuter chiqaradi
C++ da dasturi
Natijasi
Do'stlaringiz bilan baham: |