Thank you Choroba Sir for your interest , please have a look at C code.
It will basically input an array of 'n' numbers and then separate it into two arrays, one contains odd numbers and one contains even numbers. Hoping to hear from you soon.#include<stdio.h> #include<conio.h> void main() { int a[20],b[20],c[20],i,j=0,k=0,n; clrscr(); printf("Enter the number of elements"); scanf("%d",&n); printf("Enter n numbers\n"); for(i=0;i<n;i++) { scanf("%d",&a[i]); } for(i=0;i<n;i++) { if((a[i]%2)==0) { b[j]=a[i]; j++; } else { c[k]=a[i]; k++; } } printf("The even numbers are\n"); for(i=0;i<j;i++) { printf("%d\n",b[i]); } printf("The odd numbers are\n"); for(i=0;i<k;i++) { printf("%d\n",c[i]); } getch(); }
In reply to Re^2: New student, can we write this program in perl...
by rahulraina7
in thread New student, can we write this program in perl...
by rahulraina7
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |