0% found this document useful (0 votes)
30 views3 pages

C Program To Print Hollow Square Star Pattern

The document contains the code for a C program that prints a hollow square pattern of stars. It does this by: 1) Taking user input for the number of rows/columns (n) 2) Using nested for loops to iterate through each row and column 3) Printing a space for every position that is not on the first, last, or border rows/columns 4) Printing a star for the first, last rows/columns and borders to create the hollow square pattern

Uploaded by

murali167153
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
30 views3 pages

C Program To Print Hollow Square Star Pattern

The document contains the code for a C program that prints a hollow square pattern of stars. It does this by: 1) Taking user input for the number of rows/columns (n) 2) Using nested for loops to iterate through each row and column 3) Printing a space for every position that is not on the first, last, or border rows/columns 4) Printing a star for the first, last rows/columns and borders to create the hollow square pattern

Uploaded by

murali167153
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Program: To print hollow square pattern

1.

/**

2.

* C program to print hollow square star pattern

3.

*/

4.
5.

#include <stdio.h>

6.
7.

int main()

8.

9.

int i, j, n;

10.
11.

//Reads number of rows from user

12.

printf("Enter value of n : ");

13.

scanf("%d", &n);

14.
15.

//Iterates over each row one by one

16.

for(i=1; i<=n; i++)

17.

18.

//Iterates over each column of the i-th row

19.

for(j=1; j<=n; j++)

20.

21.

if(i!=1 && i!=n && j!=1 && j!=n)

22.

23.

printf(" ");

24.

25.

else

26.

27.

//Print star for first and last row and for first and last column

28.

printf("*");

29.

30.

31.
32.

//Move to the next line/row

33.

printf("\n");

34.

35.
36.
37.

return 0;
}

Prime number check


#include <stdio.h>
int main()
{
int i, n, flag;
flag = 1;
printf("Enter any number to check prime: ");

scanf("%d", &n);

for(i=2; i<n; i++)


{

if(n%i==0)
{
flag = 0;
break;
}
}

if(flag==1)
{
printf("\n%d is prime number", n);
}
else
{
printf("\n%d is not prime number", n);
}

return 0;
}

----PRINT NUMBERS INTO WORDS

You might also like