🔒 Closed Pa help for loop

Status
Not open for further replies.

Elecit23

Eternal Poster
Write a C program the will ask the user to enter an integer value between 5 and 10. Then print the character ‘@’ in this order:



If the value inputted is 6, the output will be:

@@@@@@ @@@@@@

@@@@@ @@@@@

@@@@ @@@@

@@@ @@@

@@ @@

@ @
 
C:
#include <stdio.h>
int main() {
   int i, j, rows;
   printf("Enter the number of rows: ");
   scanf("%d", &rows);
   for (i = rows; i >= 1; --i) {
      for (j = 1; j <= i; ++j) {
         printf("@");
      }
      printf(" ");
      for (j = 1; j <= i; ++j) {
         printf("@");
      }
      printf("\n\n");
   }
   return 0;
}
 
Status
Not open for further replies.

About this Thread

  • 2
    Replies
  • 437
    Views
  • 2
    Participants
Last reply from:
Elecit23

Trending Topics

Online now

Members online
1,207
Guests online
1,074
Total visitors
2,281

Forum statistics

Threads
2,287,300
Posts
29,043,658
Members
1,216,451
Latest member
lucia Z
Back
Top