Notes
Notes - notes.io |
#include <iostream>
using namespace std;
int main()
{
int n,sum=0;
cout<<"Enter the total of your numbers"<<endl;
cin>>n;
int A[n];
cout<<"Put your elements in the array"<<endl;
for(int i = 0; i < n; i++)
{
cin>>A[i];
}
for(int k = 0; k < n; k++)
{
if( A[k] > 0 )
sum = sum + A[k];
}
cout<<"nSum of positive numbers is "<<sum;
return 0;
}
// Gjeni mesataren e numrave ne nje array
#include <iostream>
using namespace std;
int main()
{
int n,sum=0, average;
cout<<"Enter the total of your numbers"<<endl;
cin>>n;
int A[n];
cout<<"Put your elements in the array"<<endl;
for(int i = 0; i < n; i++)
{
cin>>A[i];
}
for(int k = 0; k < n; k++)
{
sum = sum + A[k];
}
average = sum / n;
cout<<"nAverage of your numbers is "<<average;
return 0;
}
// Gjeni mesataren e numrave negative ne nje array
#include <iostream>
using namespace std;
int main()
{
int n,sum=0, average,counter = 0;
cout<<"Enter the total of your numbers"<<endl;
cin>>n;
int A[n];
cout<<"Put your elements in the array"<<endl;
for(int i = 0; i < n; i++)
{
cin>>A[i];
if( A[i] < 0 )
{
counter++;
sum = sum + A[i];
}
}
cout << "Sum is "<< sum;
average = sum / counter;
cout<<"nAverage of your numbers is "<<average;
return 0;
}
// Krijoni nje funksion qe gjen shumen e numrave me te medha se mesatarja ne nje array
#include <iostream>
using namespace std;
int main()
{
int n,counter = 0;
float average,sum=0; // This time we take float numbers to find the precise average and sum
cout<<"Enter the total of your numbers"<<endl;
cin>>n;
int A[n];
cout<<"Put your elements in the array"<<endl;
for(int i = 0; i < n; i++)
{
cin>>A[i];
sum = sum + A[i];
}
average = sum / n;
int new_counter = 0;
for(int i = 0; i < n; i++)
{
if( A[i] > average )
{
new_counter++;
}
}
cout<<"nThe average is " <<average << " and the total of numbers higher than the average is "<<new_counter;
return 0;
}
// Krijoni nje funksion qe gjen numrin max(min) ne nje array
#include <iostream>
using namespace std;
int main()
{
int n;
cout<<"Enter the total of your numbers"<<endl;
cin>>n;
int max,min;
int A[n];
cout<<"Put your elements in the array"<<endl;
for (int i = 0; i < n; i++)
{
cin>>A[i];
}
max = A[0];
min = A[0];
for (int i = 0; i < n; i++)
{
if( A[i] > max )
max = A[i];
else if( A[i] < min )
min = A[i];
}
cout<<"nThe max number is "<<max<<" and the min number is "<<min;
return 0;
}
//Krijoni nje funksion te quajtur range qe kthen differencen midis numrit me te madh dhe me te vogel ne nje array
#include <iostream>
using namespace std;
void range(int max, int min)
{
cout<<"nThe range between your numbers is "<< max - min;
}
int main()
{
int n,min,max;
cout<<"Enter the total of your numbers"<<endl;
cin>>n;
int A[n];
cout<<"Put your elements in the array"<<endl;
for (int i = 0; i < n; i++)
{
cin>>A[i];
}
max = A[0];
min = A[0];
for (int i = 0; i < n; i++)
{
if( A[i] > max )
max = A[i];
else if( A[i] < min )
min = A[i];
}
range(max,min);
return 0;
}
//Krijoni nje funksion qe gjen indeksin e numrit max(min) ne nje array
#include <iostream>
using namespace std;
int main()
{
int n,min,max,max_pos=0,min_pos=0;
cout<<"Enter the total of your numbers"<<endl;
cin>>n;
int A[n];
cout<<"Put your elements in the array"<<endl;
for (int i = 0; i < n; i++)
{
cin>>A[i];
}
max = A[0];
min = A[0];
for (int i = 0; i < n; i++)
{
if( A[i] > max )
{
max = A[i];
max_pos = i;
}
}
for (int k = 0; k < n; k++)
{
if( A[k] < min )
{
min = A[k];
min_pos = k;
}
}
cout << "nThe position of the max is "<< max_pos << " and the position of the minimum is "<< min_pos;
return 0;
}
//Krijoni nje funksion qe gjen nqs nje vlere e futur nga perdoruesi ekziston ne nje array
#include <iostream>
using namespace std;
void find_value(int A[],int x, int n)
{
bool exists = false;
cout<<"What do you want to find?"<<endl;
cin>>x;
for(int i = 0; i < n; i++)
{
if( A[i] == x )
exists = true;
}
if( exists == true )
cout<< x << " exists in the given array";
else
cout << x << " does not exist in the given array";
}
int main()
{
int n,x;
cout<<"Enter the total of your numbers"<<endl;
cin>>n;
int A[n];
cout<<"Put your elements in the array"<<endl;
for (int i = 0; i < n; i++)
{
cin>>A[i];
}
find_value(A,x,n);
return 0;
}
//Ndertoni nje funksion qe gjen sa here perseritet nje numer i dhene nga perdoruesi ne nje funksion
#include <iostream>
using namespace std;
int main()
{
int n,x,counter = 0;
cout<<"Enter the total of your numbers"<<endl;
cin>>n;
int A[n];
cout<<"Put your elements in the array"<<endl;
for (int i = 0; i < n; i++)
{
cin>>A[i];
}
cout<<"What do you want to find in the array?"<<endl;
cin>>x;
for( int i = 0; i < n; i++ )
if( A[i] == x )
counter++;
cout<<"Your number "<<x<<" is "<<counter<<" times used in the array.";
return 0;
}
//Krijoni nje funksion qe gjen prodhimin e numrave ne pozicionet cift ne nje array
#include <iostream>
using namespace std;
int main()
{
int n,product = 1;
cout<<"Enter the total of your numbers"<<endl;
cin>>n;
int A[n];
cout<<"Put your elements in the array"<<endl;
for (int i = 0; i < n; i++)
{
cin>>A[i];
}
for(int i = 1; i <= n; i = i + 2) //i+=2
{
product = product * A[i];
}
cout<<"The product of even indexes is "<<product;
return 0;
}
//Krijoni nje funksion qe merr si parameter nje array dhe dhe nje numer integer dhe ky funksion gjen indeksin e pare(fundit) te nje numri te dhene ne nje array
#include <iostream>
#include <vector>
using namespace std;
void find_pos(int A[] , int n,int x)
{
bool isFound = false;
int pos = 0, first_pos, counter = 0;
cout<<"What do you want to find? ";
cin>>x;
for(int i = 0; i < n; i++)
{
if( A[i] == x )
{
counter++;
pos = i;
if( counter == 1 )
first_pos = i;
isFound = true;
}
}
if(isFound)
cout<<"nThe last position of your number is "<<pos<<" and the first position of your number is "<<first_pos;
else
cout<<"n Your number is not a part of this array";
}
int main()
{
int n,x;
cout<<" Enter the total of your elements ";
cin>>n;
int A[n];
for(int i = 0; i < n; i++)
{
cin>>A[i];
}
find_pos(A,n,x);
return 0;
}
|
Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...
With notes.io;
- * You can take a note from anywhere and any device with internet connection.
- * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
- * You can quickly share your contents without website, blog and e-mail.
- * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
- * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.
Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.
Easy: Notes.io doesn’t require installation. Just write and share note!
Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )
Free: Notes.io works for 12 years and has been free since the day it was started.
You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;
Email: [email protected]
Twitter: http://twitter.com/notesio
Instagram: http://instagram.com/notes.io
Facebook: http://facebook.com/notesio
Regards;
Notes.io Team