I am still very new to c++ and i am totally confused on loops so can anyone help me write a program to

"Write a program that finds and prints all prime numbers less than or equal to n, where n is a number input by the user."

This is the template were supposed to use

Code:

#include <iostream>
using namespace std;
// ======================
// main function
// ======================
int main()
{
// Variable declarations
int n, i, k;
int counter = 0;
bool isprime;
//Welcome user to the program
//Prompt user for an integer
// Outer loop, tests to see if k is prime for k=2 to n
{
// Assume k is prime
// Inner loop tests whether or not k is prime
{
}
// Check if flag isprime is still true
}
//Output total number of primes found
}

Our output is supposed to be

Program to compute prime numbers less than n.

Enter a positive integer n: 10

2 3 5 7

There are 4 primes less than 10.

mmartin@cs.csustan.edu~/cs1500/lab3) a.out

Program to compute prime numbers less than n.

Enter a positive integer n: 50

2 3 5 7 11 13 17 19 23 29 31 37 41 43 47

There are 15 primes less than 50.

Thanks sooooooo much