#include<stdio.h>
int main()
{
int array[100][100];/// declare a 2D Array.
int i,j,r,c;
printf("Please Enter The Row Number:");
scanf("%d",&r);
printf("Please Enter The Column Number:");
scanf("%d",&c);
printf("Please Enter %d X %d Element Of the array: ",r,c);
for(i=0; i<r; i++) ///scan array element
{
for(j=0; j<c; j++)
{
scanf("%d",&array[i][j]);
}
}
printf("The Odd Element of the array:");
for(i=0; i<r; i++)
{
for(j=0; j<c; j++)
{
if(array[i][j]%2!=0)///Checking the number is odd or not.
{
printf("%d ",array[i][j]);
}
}
printf("");
}
return 0;
}
Output
Please Enter The Row Number: 3
Please Enter The Column Number: 3
Please Enter 3 x 3 Element Of the array:
1 2 3
4 5 6
7 8 9
The Odd Element of the array:
1 3
5
7 9
Add your comment