Thursday, 7 July 2016

Print Multiples of 7 | C++ Programming Basics

Print Multiples of 7 | C++ Programming Basics

// A program that prints all number between 1 and N that are divisible by 7

#include <iostream>
using namespace std;

int main()
{
    int last_number;
    cout<<"Please enter the number to which you want to print the multiples of 7"<<endl;
    cin>>last_number;

    for (int counter=1;counter<=last_number;counter++){
       if ((counter%7)==0)
           cout<<counter<<endl;
    }

    return 0; 
}

No comments

Post a Comment

Recent Posts