63 169
Assignments Done
99,3%
Successfully Done
In July 2018

Answer to Question #44721 in C++ for jalal

Question #44721
You are given n you are required to print the following rhombus:
----------------------------------------------------------------
Example:5

1
121
12321
1234321
123454321
1234321
12321
121
1
Expert's answer
#include <stdio.h>
#include <stdlib.h>
int main()

    int N = 5;   
     
// Top part
    for (int row = 1; row <= N; row ++)
{
for (int col = 1; col <= N - row; col ++)
printf(" ");
for (int col = 1; col <= row; col ++)
printf("%d", col);
for (int col = row - 1; col >= 1; col --)
printf("%d", col);
printf("\n");
}

// Bottom part
    for (int row = N - 1; row >= 1; row --)
{
for (int col = 1; col <= N - row; col ++)
printf(" ");
for (int col = 1; col <= row; col ++)
printf("%d", col);
for (int col = row - 1; col >= 1; col --)
printf("%d", col);
printf("\n");
}
     
    system("pause");
return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions