0

Error

What’s wrong with this code in c language #include <conio.h> #include <stdio.h> int main() { int i,n,j; printf("enter a number"); scanf("%d",&n); for (i=0;i<n;i++) { for(j=0;j<n;j++) if(i==0 || j==0 || i==n-1 || j==n-1 || j+i==n-1) printf("*"); else printf(" "); return 0; } It said error:unpaired curly brackets.

29th Nov 2019, 4:47 PM
Saba
3 Antworten
+ 8
Saba I already fixed your previous code have an look here https://code.sololearn.com/cdVy8U02Cpr5/?ref=app it's same as that problem int main() { // n denotes size which should be odd int i, j, n; scanf("%d", &n); // Function calling //pattern(n); for (int i = 0; i < n; i++) { // Loop denoting columns for (int j = 0; j < n; j++) { // Checking boundary conditions and main // diagonal and secondary diagonal conditions if (i == 0 || j == 0 || i == j || i == n - 1 || j == n - 1 || i + j == n - 1) printf("*"); else printf(" "); } printf("\n"); } return 0; }
29th Nov 2019, 5:01 PM
GAWEN STEASY
GAWEN STEASY - avatar
+ 1
after for loop you opend a curly bracket but you didnt close it by the way your program doesnt need conio.h header file
29th Nov 2019, 5:30 PM
smrmodares
smrmodares - avatar
0
In your code, there were 2open braces & 1 closed brace Add 1closed curly brace at the end
29th Nov 2019, 4:52 PM
Prasanth