5
54
543
5432
54321
543210
54321
5432
543
54
5
Data requirement:-
Input Data:- row_size
Output Data:-in or inn(for python)
Additional Data:-out
Program in C
Here is the source code of the C Program to print the Solid Half Diamond Number Pattern.
Code:
#include<stdio.h>
#include<math.h>
int main()
{
    int out,in;
    printf("Enter the row size:");
	    int row_size;
	    scanf("%d",&row_size);
	   for(out=row_size;out>=-row_size;out--)
	    {
	     for(in=row_size;in>=abs(out);in--)
	     {
	    	 printf("%d",in);
	     }
	    	 printf("\n");
}}
Enter the row size:5
5
54
543
5432
54321
543210
54321
5432
543
54
5
Program in C++
Here is the source code of the C++ Program to print the Solid Half Diamond Number Pattern.
Code:
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
    int out,in;
    cout<<"Enter the row size:";
	    int row_size;
	    cin>>row_size;
	    for(out=row_size;out>=-row_size;out--)
	    {
	     for(in=row_size;in>=abs(out);in--)
	     {
	    		 cout<<in;
         }
	    	 cout<<"\n";
}}
Enter the row size:4
4
43
432
4321
43210
4321
432
43
4
Program in Java
Here is the source code of the Java Program to print the Solid Half Diamond Number Pattern.
Code:
import java.util.Scanner;
public class NumberPattern17 {
	public static void main(String[] args) {
		Scanner cs=new Scanner(System.in);
        int out,in;
	    System.out.println("Enter the row size:");
	    int row_size=cs.nextInt();
	    for(out=row_size;out>=-row_size;out--)
	    {
	     for(in=row_size;in>=Math.abs(out);in--)
	     {
	    	 System.out.print(in);
	     }
	    	 System.out.println();
	    }
	    cs.close();
	}
}
Enter the row size:
5
5
54
543
5432
54321
543210
54321
5432
543
54
5
Program in Python
Here is the source code of the Python Program to print the Solid Half Diamond Number Pattern.
Code:
row_size=int(input("Enter the row size:"))
for out in range(row_size,-(row_size+1),-1):
    for inn in range(row_size,abs(out)-1,-1):
        print(inn,end="")
    print("\r")
Enter the row size:3
3
32
321
3210
321
32
3
 

0 Comments
Please do not Enter any spam link in the comment box