print array c++
void printArray(int a[],int n){
for(int i=0;i<n;i++)
cout<<a[i]<<" ";
cout<<endl;
}
print array c++
void printArray(int a[],int n){
for(int i=0;i<n;i++)
cout<<a[i]<<" ";
cout<<endl;
}
print an array c++
#include <iostream>
using namespace std;
int main() {
int numbers[5] = {7, 5, 6, 12, 35};
cout << "The numbers are: ";
// Printing array elements
// using range based for loop
for (const int &n : numbers) {
cout << n << " ";
}
cout << "\nThe numbers are: ";
// Printing array elements
// using traditional for loop
for (int i = 0; i < 5; ++i) {
cout << numbers[i] << " ";
}
return 0;
}
c++ print every element in array
#include<iostream>
int main()
{
int array[8] = {1,2,3,4,5,6,7,8};
int i = 0;
while (i <= sizeof(array)/sizeof(int))
{
std::cout << array[i];
i++;
}
}
prints out the elements in the array c++
for (auto i : a){ //C++11
cout << i<< " ";
}
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us