The student of group 103, Shermatova Sarvinoz



Download 337,59 Kb.
Sana09.06.2022
Hajmi337,59 Kb.
#648486
Bog'liq
5-independent work


The student of group 103,


Shermatova Sarvinoz,
is independent of programming.

1.Why will the following code give an error? Need to explain in detail.


char p;
char *p=&p;


cin>>p; - it had to be that way.

2.You created a dynamic array in the following form. Explain the error of this code:



The first line should have been double *x, not double x[].
The last line should have delete [] x, not delete x.

3.Explain why this pointer is needed?


Landscaping and study of areas where the function can be tested in the table. The problem is that the accelerator area will have undesirable features. In this section, the area of the hidden objects is nominally referenced in order to receive new payments in the functions. Special areas will be offered special facilities for the launch of weather-related facilities.



4. (Analysis of input data) Write a program that first reads an integer for the size of the array, then reads the numbers into the array, calculates their average value and finds out how many numbers are above average.
Program code:
#include
using namespace std;
double middle(const double* list, int size)
{double s=0;
for(int i=0;is+=list[i];
return s/size;}
int large(const double* massive, int size)
{int s=0;
double Middle = middle(massive,size);
for(int i=0; i{if (massive[i]> Middle)
s++;}
return s;}
int main()
{int n;
cin>>n;
double a[n];
for(int i=0; icin>>a[i];
int max = large(a,n);
double Middle = middle(a,n);
cout<<"Average value = "<cout<<"The number of elements greater than the average value ="<return 0;}

5.(Printing various numbers) Write a program that first reads an integer for the size of the array, then reads the numbers into an array and displays different numbers (that is, if a number appears several times, it is displayed only once). (Hint: read the number and save it in the array if it is new. If the number is already in the array, discard it. After entering the array contains various numbers.).
Program code:
#include
using namespace std;
setds;
set::iterator it;
void printArray(int* c, int n)
{
for(int i=0; ids.insert(*(c+i));
for(it=ds.begin(); it!=ds.end(); it++)
cout<<*it<<" ";}
int main(){
int size;
cout<<"Enter the massive size ";
cin>>size;
int list[size];
cout<<"Enter the massive elements \n";
for(int i=0; icin>>list[i];
printArray(list,size);
}


Download 337,59 Kb.

Do'stlaringiz bilan baham:




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish