a simple program to print a square of asterisk, side is entered by the user. i wrote it without a function, but i can't do it with a function. what is the return type of the function? void or char? with void i use printf('*'); but then in the main function what should i use to print the square?
Code:
#include <stdio.h>#include <math.h>
#include <conio.h>
#include <stdlib.h>
#include <time.h>
char print(int x);
int main() {
int x1;
scanf_s("%d",&x1);
printf("%s",print(x1));
_getch();
return 0;
}
char print(int x) {
int j;
for(int i = 1; i <= x; i++) {
for(j = 1; j <= x; j++) {
return '*';
}
if (j==x) return '\n';
}
}