Can you write a c program for the following output?

Systems Architecture
7th Edition
ISBN:9781305080195
Author:Stephen D. Burd
Publisher:Stephen D. Burd
Chapter2: Introduction To Systems Architecture
Section: Chapter Questions
Problem 2VE: A(n) __________ is a storage location implemented in the CPU.
icon
Related questions
Question
100%
Can you write a c program for the following output?
Sample Input
Sample Output
*****
*
*
*
*
*****
6
******
*
*
*
*
******
Transcribed Image Text:Sample Input Sample Output ***** * * * * ***** 6 ****** * * * * ******
Expert Solution
Step 1

Program:

 

#include <stdio.h>

int main()
{
     int number;
    
    printf("Input:\n");
    scanf("%d", &number); //reading number of rows or columns
    
    printf("\nOutput:\n");
    

   //loop to print pattern
    for (int i = 1; i <= number; i++){

      //for printing first and last row
        if (i == 1 || i == number){
            for (int j = 1; j <= number; j++)
                printf("*");
        }
        

       //for printing all rows except first and last
        else{
            for (int j = 1; j <= number; j++){
                if (j == 1 || j == number)
                    printf("*");
                else
                    printf(" ");
            }
        }
        
        printf("\n");
    }
    
    return 0;
}

trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Print statement
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Recommended textbooks for you
Systems Architecture
Systems Architecture
Computer Science
ISBN:
9781305080195
Author:
Stephen D. Burd
Publisher:
Cengage Learning
Systems Analysis and Design (Shelly Cashman Serie…
Systems Analysis and Design (Shelly Cashman Serie…
Computer Science
ISBN:
9781305494602
Author:
Scott Tilley, Harry J. Rosenblatt
Publisher:
Cengage Learning