C++ code for array of five numbers.
#include <iostream.h> void main() { int A[5],n=0,m=0; cout<<"Enter numbers : "; for(int i=0;i<5;i++) { cin>>A[i]; if(A[i]%2==0) n++; else m++; } cout<<"\nNo. of odd numbers = "<<m; cout<<"\nNo. of even numbers = "<<n; }
#include <iostream.h> void main() { int A[5],n=0,m=0; cout<<"Enter numbers : "; for(int i=0;i<5;i++) { cin>>A[i]; if(A[i]%2==0) n++; else m++; } cout<<"\nNo. of odd numbers = "<<m; cout<<"\nNo. of even numbers = "<<n; }
OUTPUT-
Enter numbers : 6 2 3 4 5 no. of odd numbers =2 no. of even numbers =3
Comments :
Post a Comment