在C ++中添加两个数组

c_cpp
阅读 34 收藏 0 点赞 0 评论 0

AddTwoArrays.cpp
#include <iostream>
using namespace std;
 
main()
{
   int first[20], second[20], c, n;
   
   cout << "Enter the number of elements in the array ";
   cin >> n;
 
   cout << "Enter elements of first array " << endl;
 
   for ( c = 0 ; c < n ; c++ )
      cin >> first[c];
 
   cout << "Enter elements of second array " << endl;
 
   for ( c = 0 ; c < n ; c++ )
      cin >> second[c];
 
   cout << "Sum of elements of two arrays " << endl;
 
   for ( c = 0 ; c < n ; c++ )
      cout << first[c] + second[c] << endl;
     
   return 0;
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号