Esta es una solución según las restricciones que tienes, pero te la he hecho en c++.
#include <iostream>
#include <sstream>
#include <cstring>
using namespace std;
const int MULTIPLO = 5;
const int RANGO = 20;
string multiplos()
{
stringstream flujo;
for(int i=0 ; i < RANGO; i++)
{
if(i < RANGO-1)
flujo << i*MULTIPLO << ", ";
else flujo << i*MULTIPLO << '.';
}
return flujo.str();
}
int main()
{
cout << multiplos() << endl;
}
Hay otra manera de hacerlo, mediante el uso de vectores. que tiene mucha relación con los registros, creo que no te dejarán usarlo pero te lo pongo de igual modo.
#include <iostream>
#include <vector>
using namespace std;
const int MULTIPLO = 5;
const int RANGO = 20;
vector <int> multiplos()
{
vector <int> NumMult;
for(int i = 0 ; i < RANGO; i++)
{
NumMult.push_back(MULTIPLO*i);
}
return NumMult;
}
int main()
{
for (int i = 0; i < multiplos().size(); i++)
{
cout << multiplos()[i] << endl;
}
}
Si estas empezando con la programación creo que la mejor solución es:
Si te vale esto
#include <stdio.h>
#define MULTIPLOS 20
#define TOMADOS 5
int multiplos(int paso)
{
return (paso*TOMADOS);
}
int main()
{
int i,paso;
paso = 1;
for(i=0;i<MULTIPLOS;i++)
{
printf("%i\n" ,multiplos(paso));
paso++;
}
return 0;
}