You're online now.

Hurray! you are online now.

How to make swastik in c and cpp programming language

// C programming language
    #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 langauge
    
    #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;
    }
🖤 0
Buy me coffee ☕

Comments

Oops!

No comments here...