Home C C++ Java Python Perl PHP SQL JavaScript Linux Selenium QT Online Test

Home » C++ » Solved Programs » Program to do grouping of array elements

C++ program to do grouping of array elements


#include
#include<iostream>
using namespace std;

#define ARRSIZE 50
#define GROUP_SIZE 20

//function with read input from user and returns it
int * getArrary();

int main(){
    
int *ptr = getArrary();

cout<<endl;

for(int i = 1; i<=ARRSIZE; i++){
if((i>GROUP_SIZE) && ((i-1)%GROUP_SIZE==0))
cout<<"\n";
cout<<" "<<*ptr++;;

if(i%GROUP_SIZE!=0 && i!=ARRSIZE)
cout<<",";
    
}
}

int * getArrary(){
    
static int intArr[ARRSIZE];

for(int i = 0; i>intArr[i];
} 

return intArr;
}

Code compiled on g++ compiler

c++ program to do grouping of array elements