+ 1

Hey !can anyone send me examples with arrays?

For exmp.including how to find the size of array,the sum,the min and max.output of the elements that are in the array,how to find only positiv and only negative numbers?

26th Nov 2018, 2:37 PM
Florentina Çela
Florentina Çela - avatar
3 Answers
+ 5
[Albanian Lang.] Varet ne cfare gjuhe te duhet por ne pergjithesi qe te punohet me arrays(vektoret) perdorim indeksimin nga 0 dhe e gjithe taktika eshte te luash me indekset e elememteve. 1. Keshtu ne thuajse te gjitha gjuhet e programimit ekziston opsioni: array_name.length qe tregon nr e elementeve te array. 2. Per te gjetur shumen e elementeve ne fillim deklaron nje variabel te quajtur shuma dhe pastaj: for(int i = 0; i<array.length; i++) { shuma += array[i]; } cout << shuma; 3. Njelloj per te gjetur nr pozitive ose negative int positives = []; int j = 0; for(int i = 0; i<array.length; i++) { if(array[i]>0) { positives[j] = array[i]; j++; } else { continue; } } cout << positives; Me vjen keq nese ka gabime sintakse gjate kompilimit, sepse une punoj ne javaScript edhe kam kohe qe nuk e praktikoj C++ por kjo eshte rruga. Nese akoma te duhet ndihme, mos ngurro te pyesesh!
26th Nov 2018, 2:52 PM
Ledio Deda
Ledio Deda - avatar
0
Faleminderit shumm
26th Nov 2018, 2:58 PM
Florentina Çela
Florentina Çela - avatar
0
WEEK-5A- Write a C program to find the minimum, maximum in an array of integers. #include<stdio.h> int main() { int a[50],i,n,large,small; printf("How many elements:"); scanf("%d",&n); printf("Enter the Array:"); for(i=0;i<n;++i) scanf("%d",&a[i]); large=small=a[0]; for(i=1;i<n;++i) { if(a[i]>large) large=a[i]; if(a[i]<small) small=a[i]; } printf("The largest element is %d",large); printf("\nThe smallest element is %d",small); return 0;
8th Dec 2018, 8:54 AM
Harshini Reddy Revuri
Harshini Reddy Revuri - avatar