functions, strings

Hello!
I have to write a program writting a line made of * if the input number is odd and 0 if the number is even. Have to use functions with stings. I could nt find the example.


#include<iostream>
#include<string>
using namespace std;
int main() {
int a;
cout<<"Input number smaller than 10 ";
cin>>a;

void line1(){
for (int i=1, i<=a; i++){
cout<<"*";
}}

void line2() {
for (int b=1, b<=a; b++){
cout<<"=";
}}

if (a%2==0)
cout<<line1;
else
cout<<line2
return 0;
}

please, what is wrong with that?
Last edited on
Please,
why do I get here build error 1???


#include<iostream>
using namespace std;
int main () {
int a;
cin>>a;
cout<<"a= "<<a;
return 0;
}
in your first post you are declaring functions inside another function (your main()), that doesnt work.
Topic archived. No new replies allowed.