|
Axborot texnologiyalari (Dasturlash)
|
bet | 2/3 | Sana | 18.11.2023 | Hajmi | 0,92 Mb. | | #100887 |
Bog'liq Amaliy topshiriq 1 с (2)Dastur Natijasi:
Quyidagi masalaning dasturini tuzing:
Foydalanuvchi ismini, familyasini va sharifini alohida satrlar sifatida kiritganda, ulardagi harflarning ASCII jadvalidagi tartib raqamlari yi`g`indisini bitta siklda hisoblash dasturini tuzing (Har bir talaba o’zining ism familiyasini kiritgan holda yechishi shart).
Dastur kodi:
#include
#include
using namespace std;
int main()
{
char a[50],b[50],c[50];
int a1=0,b1=0,c1=0,x,y,z,key=1;
cout<<"Ism: "; cin>>a;
cout<<"Familiya: "; cin>>b;
cout<<"Sharf: "; cin>>c;
while(1)
{
for(int i=0; i{
a1+=int(a[i]);
key=0;
}
for(int i=0; i{
b1+=int(b[i]);
key=0;
}
for(int i=0; i{
c1+=int(c[i]);
key=0;
}
if(key==0)
break;
}
cout<<"Ism: "<cout<<"Familiya: "<cout<<"Sharf: "<}
Dastur Natijasi:
(Summa) Quyidagi matematik ifodani summasini hisoblovchi dasturni funksiya yordamida tuzing:
Dastur kodi:
#include
using namespace std;
void func(int n)
{
double s=0;
for(int i=1; i<=n; i+=2)
{
s+=1.0*i/(i+2);
}
cout<<"Natija = "<}
int main()
{
int n; cin>>n;
func(n);
}
Dastur Natijasi:
1, 2, 3; 4, 5, 6 va 7, 8, 9 sonlari argument sifatida yuborilganda, ularning yig`indisini, o`rta arifmetgini va o`zaro ko`paytmasini hisoblab, konsolga chiqaruvchi funksiya yarating.
Dastur kodi:
#include
using namespace std;
void func(double a1, double a2, double a3, double a4, double a5, double a6, double a7, double a8, double a9)
{
double sum=0,avg=0,p=1;
sum=a1+a2+a3+a4+a5+a6+a7+a8+a9;
p=a1*a2*a3*a4*a5*a6*a7*a8*a9;
cout<<"Yig'indi = "<avg=1.0*sum/9;
cout<<"O'rtacha = "<cout<<"Ko'paytma = "<
}
int main()
{
double a1,a2,a3,a4,a5,a6,a7,a8,a9;
cout<<"Io'qqizta son kiriting: ";
cin>>a1>>a2>>a3>>a4>>a5>>a6>>a7>>a8>>a9;
cout<<"Natija\n";
func(a1,a2,a3,a4,a5,a6,a7,a8,a9);
}
|
| |