Description

C Programming language

// Online C compiler to run C program online
#include <stdio.h>


int main()
{

    int n = 9;
    
    for(int i = 1; i<=n; i++){
        for(int j=1; j<=n; j++){
            if(i==n/2 + 1 || j == n / 2 + 1 || (i==1 && j >= n/2 + 1) || (i == n && j <= n / 2) || (j == 1 && i <= n/2) || (j == n && i >= n/2 + 1)){
                printf("*");
            }else{
                printf(" ");
            }
        }
        printf("\n");
    }

    return 0;
}

C++ Programming language


#include<iostream>

using namespace std;

int main()
{

    int n = 9;
    
    for(int i = 1; i<=n; i++){
        for(int j=1; j<=n; j++){
            if(i==n/2 + 1 || j == n / 2 + 1 || (i==1 && j >= n/2 + 1) || (i == n && j <= n / 2) || (j == 1 && i <= n/2) || (j == n && i >= n/2 + 1)){
                cout<<"*";
            }else{
                cout<<" ";
            }
        }
        cout<<endl;
    }

    return 0;
}

 

Comments

Login is mandatory to comment Please login

Recommended Posts

User Login System in C programming language

We create a login System program which takes username and password from the user.

Program to print a message without using semicolon in c programming

How to write a c program to print a message without using semicolon in c programming language.

Function call by value in c programming language

The call by value technique of passing arguments to a function copies the particular value of an argument into the formal parameter of the function.

Call by Reference in C programming language

When we call a function and pass the variable / parameter in the function, when passing the address of the actual arguments from the calling function, that's why it is called call by reference.

C program to replace vowels with special characters

Write a c program to replace vowels with special characters.

File Read in C | File Handling | How to Read File

Write a program to read the file in c File Handling. How to read file is the main topic of file handling.