What's new

C & C++ Arrays C++

cirex

Forum Veteran
Elite
Joined
Nov 10, 2018
Posts
2,600
Solutions
5
Reaction
2,645
Points
1,019
1647998308049.png

mga idol baka pwede patulong sa syntax kung pano yung sum of two arrays salamat po in advance
1647998413289.png


#include <iostream> using namespace std; int main() { int even[5]; int odd[5]; int sum; cout<<"Enter Elements in Array 1:"<<endl; for(int index1=0; index1<5; index1++){ cout<<"index["<<index1<<"]:"; cin>>even[index1]; } cout<<"\nEnter Elements in Array 2:"<<endl; for(int index2=0; index2<5; index2++){ cout<<"index["<<index2<<"]:"; cin>>odd[index2]; } cout<<"\nElements 1: " <<endl; for(int index1=0; index1<5; index1++){ cout<<even[index1]; } cout<<"\n\nElements 2: " <<endl; for(int index2=0; index2<5; index2++){ cout<<odd[index2]; } cout<<"\n\nSum of two Arrays"; return 0; }
 

Attachments

boss ilalagay kay sum yung sum ng 3 7 11...?
C++:
#include <iostream>

using namespace std;

int main()
{
    int odd[5] = {2,4,6,8,10};
    int even[5] = {1,3,5,7,9};
    int sum = 0;

        for(int i = 0; i < 5; i++)
        {
           sum += odd[i] + even[i];
        }
        cout << "\nSum of 2 array: " << sum;
       
        // OUTPUT: Sum of 2 array: 55
    return 0;
}

pa feedback nalang kung tama kasi nag aaral palang din ako cpp eh
 
Last edited:
boss ilalagay kay sum yung sum ng 3 7 11...?
C++:
#include <iostream>

using namespace std;

int main()
{
    int odd[5] = {2,4,6,8,10};
    int even[5] = {1,3,5,7,9};
    int sum = 0;

        for(int i = 0; i < 5; i++)
        {
           sum += odd[i] + even[i];
        }
        cout << "\nSum of 2 array: " << sum;
      
        // OUTPUT: Sum of 2 array: 55
    return 0;
}

pa feedback nalang kung tama kasi nag aaral palang din ako cpp eh
Mali po paps e, pero salamat parin po!
1648002818732.png

ganito po kasi dapat output nya e
 

Attachments

ahh wait
C++:
#include <iostream>

using namespace std;

int main()
{
    int even[5] = {2,4,6,8,10};
    int odd[5] = {1,3,5,7,9};
    int sum = 0;
        cout << "\nSum of 2 array\n";
        for(int i = 0; i < 5; i++)
        {
            cout << odd[i] << " + " << even[i] << " = " << odd[i] + even[i] << endl;
        }

    return 0;
}

Rich (BB code):
OUTPUT:

Sum of 2 array
1 + 2 = 3
3 + 4 = 7
5 + 6 = 11
7 + 8 = 15
9 + 10 = 19
 
Last edited:
ahh wait
C++:
#include <iostream>

using namespace std;

int main()
{
    int even[5] = {2,4,6,8,10};
    int odd[5] = {1,3,5,7,9};
    int sum = 0;
        cout << "\nSum of 2 array\n";
        for(int i = 0; i < 5; i++)
        {
            cout << odd[i] << " + " << even[i] << " = " << odd[i] + even[i] << endl;
        }

    return 0;
}

Rich (BB code):
OUTPUT:

Sum of 2 array
1 + 2 = 3
3 + 4 = 7
5 + 6 = 11
7 + 8 = 15
9 + 10 = 19
Salamat po
 

Similar threads

Back
Top