http://i37.tinypic.com/118f1iu.jpg **Question and output sample is in the link**
ID: 3614629 • Letter: H
Question
http://i37.tinypic.com/118f1iu.jpg**Question and output sample is in the link***
I'm stuck and this is all I have so far...=[
[code]
int main() {
int a,b,c,i,j,k,n;
printf("Enter an odd number in the range 1 to 19for the number of rows of the diamond: ");
scanf("%d",&n);
//for the first half of diamond
for(i=n;i>0;i--) {
for(j=1;j<i;j++) {
printf(""); }
for(k=j-1;k<n;k++) {
printf("*");
printf(" ");
}
printf(" ");
}
//for the second half of diamond
for(a=n-1;a<n && a!=-1;a--) {
for(b=n;b>a;b--) {
printf(""); }
for(c=0;c<a;c++) {
printf("*");
printf(" ");
}
printf(" "); }
return 0;
}
[/code]
Explanation / Answer
please rate - thanks you were just missing the check for oddotherwise it was perfect #include #include int main() { int a,b,c,i,j,k,n; printf("Enter an odd number in the range 1 to 19for the number of rows of the diamond: "); scanf("%d",&n); while(n%2==0) {printf("Invalid entry for the number ofrows "); printf("Enter an odd number in the range 1to 19 for the number of rows of the diamond: "); scanf("%d",&n); } //for the first half of diamond for(i=n;i>0;i--) { for(j=1;jRelated Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.