Friday 3 June 2016

Write a program that inputs five numbers and passes the to a function one at a time.The function returns true if the integer is even and false otherwise.

#include<iostream.h>
#include<conio.h>
char check (int n);
void main()
{
      clrscr();
      int arr[5];
      char r;
      cout<<"Enter five numbers: "<<endl;
      for(int i=0; i<5; i++)
            cin>>arr[i];
      for(i = 0; i<5; i++)
      {
            r = check(arr[i]);
            if(r == 't')
                cout<<arr[i]<<" is even. "<<endl;
            else
               cout<<arr[i]<<"  is not even. "<<endl;
      }
      getch();
}

char check(int n)
{
      if(n%2 == 0)
            return 't';
      else
            return 'f';
}
Share:

1 comment:

Popular Posts

Recent Posts

Unordered List

Text Widget

Pages

About Me

My photo
A group of two, with a little hope of helping beginners to learn how to code :)
Powered by Blogger.

Comments

Facebook

Ad Home

Follow Us

Random Posts

Sponsor

Recent Posts

Header Ads

Popular Posts

Copyright © Functions in C++ | Powered by Blogger

Design by ThemePacific | Blogger Theme by NewBloggerThemes.com | Distributed By Blogger Templates20