Create a program that will display all the composite numbers from 0 to 1000 and has a maximum column of 5 . A composite number is a positive integer that has at least one positive divisor other than one or itself.
SAMPLE OUTPUT:::::::::::::
4 6 8 9 10
12 14 15 16 18
20 21 22 24 25
26 27 28 30 32
...... AND SO ON.
here's my code.. how can i arrange it to become 5 columns only? and also there's something wrong with my code.. the output is counting by 4,6,8,10,12,14,16 and so on.. please help me to solve that problem
#include <iostream>
#include <conio.h>
#include<iomanip>
using namespace std;
int main()
{
int num=1;
while (num<=1000)
{if((num%2==0)&& (num!=2))
cout<<setw(4)<<num<<setw(6);
num++;
}
getch ();
}