Problem : What are the output of the following program:
Input the number of elements to be stored in the array : 5
element - 0 : 1
element - 1 : 2
element - 2 : 3
element - 3 : 4
element - 4 : 5
2 4 1 3 5
- #include <stdio.h>
- void main() {
- int arr1[10], arr2[10], arr3[10];
- int i,j=0,k=0,n;
- printf("Input the number of elements to be stored in the array :");
- scanf("%d",&n);
- printf("Input %d elements in the array :\n",n);
- for(i=0;i<n;i++){
- printf("element - %d : ",i);
- scanf("%d",&arr1[i]);
- }
- for(i=0;i<n;i++)
- {
- if(arr1[i]%2 == 0)
- {
- arr2[j] = arr1[i];
- j++;
- }
- else
- {
- arr3[k] = arr1[i];
- k++;
- }
- }
- for(i=0;i<j;i++)
- {
- printf("%d ",arr2[i]);
- }
- for(i=0;i<k;i++)
- {
- printf("%d ", arr3[i]);
- }
- }
একটি মন্তব্য পোস্ট করুন