Write a Program in C++ to Find Odd Numbers in an Array

In this problem we will learn how to find the odd number in an array. The program will received input from the user which is numeric values . In logic there is simple function just check where the reminder is one or greater then one just print out that numbers in from a loop.

Source Code 

#include<iostream>
using namespace std;
int main ()
{
 int num [7];
 for (int i =0;i<7;i++)
 {
  cout<<" Enter Your Number : ";
  cin>>num[i];
 }
 cout<<endl<<endl;
 cout<<" The Odd number are: \n ";
 for (int i =0;i<7;i++)
 {
  if (num[i]%2==1)
  {
  cout<<endl;
  cout<<num[i];
  }
 }
}

Output of the Program

C++ Programming

Share on Google Plus

About Asad

Asad Niazi is Software Engineer , Programmer, Web Developer and a young mentor of BloggersTown and PProgramming. Asad Love to writes about Technology, Programming, Blogging and make money online.

1 comments:

  1. I am beginner and i learn a lot of basic concept of C++ here . thanks for such a nice content

    ReplyDelete