physics chemistry maths science forums
become expert I help I sign up I login
refer a friend - earn nickels!!   
 advanced
 
Home
Ask & Discuss Questions
Study Material
Experts Zone
Hang Out!

Ask & Discuss Questions with Community & Experts

Moderation Team
 90 chars left    advanced
Ask iit jee aieee pet cbse icse state board community Community Discussion Question: c++-plz help
Forum Index -> Course Material like the article? email it to a friend.  
Author Message
ra_kv1_mdu (31)

Cool goIITian

Olaaa!! Perrrfect answer. 5  [8 rates]

ra_kv1_mdu's Avatar

total posts: 54    
offline Offline
Write a function in c++ which accepts a 2D array of integers, number of rows and  number of columns as arguments and assign the elements which are divisible by 3 or 5 into a one dimensional array of integers.                                                               
    
raulrag009 (1194)

Blazing goIITian

Olaaa!! Perrrfect answer. 202  [294 rates]

raulrag009's Avatar

total posts: 637    
offline Offline
Void func(a[20][20],row,col)
{
int i,j,b[100],l;
cout<<"enter the no of rows and coloumns\n";
cin>>row>>col;
cout<<"enter the elements of the 2D array\n";
for(i=0;i<row;i++)
{
for(j=0;j<col;j++)
{ cin>>a[i][j];
}
}
for(i=0;i<row;i++)
{
for(j=0;j<col;j++)
{   if(a[i][j]%3==0 ||a[i][j]%5==0)
{
for(l=0;l<row+col;i++)
{ a[i][j]=b[l];
}}
else cout<<"thank you\n";
}}
 
for(l=0;l<row+col;l++)
{
cout<<"the elements are\n";
cout<<b[l];
}
}
 
 
 
 this reply: 5 points  (with Olaaa!! Perrrfect answer.   in 1 votes )   [?]
 
You have to be logged on to rate
  
nadeemoidu (1184)

Blazing goIITian

Olaaa!! Perrrfect answer. 200  [292 rates]

nadeemoidu's Avatar

total posts: 487    
offline Offline
I dont understand the above answer but i don't think it will work . here's a better one.


void func(int a[10][10],int row,int col)
{
int i,j,b[100],k=0;

for(i=0;i<row;i++)
for(j=0;j<col;j++)

   if(a[i][j]%3==0 ||a[i][j]%5==0)
      
        b[k++]= a[i][j];

cout<<"\n\nThe required array is  \n";
for(i=0;i<k;i++)
cout<<'\t'<<b[i];
}


 this reply: 5 points  (with Olaaa!! Perrrfect answer.   in 1 votes )   [?]
 
You have to be logged on to rate
  
 
Forum Index -> Course Material
Go to:   

Top Offers for goIITians
Correspondence Courses
Brilliant Tutorials
Narayana Institute
Aakash Institute
Classroom/Crash Courses
Narayana - Kota , Delhi , Others
Brilliant Tutorials - Class , Crash
Aakash Institute - Medical , Engg
Online Test Series
Brilliant Tutorials
Narayana Institute
Aakash Institute
Mahesh Tutorials
AMITY      Sri Chaitanya