15.9.15

print all integer which are divisible by 3 using c++

/* Series of Integer which is divide by 3 */

#include<iostream>
#include<conio.h>
using namespace std;
int series(int start,int last)
{
    cout<<"The series which is divide by 3 is:"<<endl;
    for(int i=start;i<=last;i++)
    {
        if(i%3==0)
        {
            cout<<i<<"\t";
        }
    }
}
int main()
{
    int start,last;
    cout<<"Enter start value:"<<endl;
    cin>>start;
    cout<<"Enter Last value:"<<endl;
    cin>>last;
    series(start,last);
    getch();
    return 0;
}

No comments:

Post a Comment

Comment Here