- This topic is empty.
Viewing 1 post (of 1 total)
Viewing 1 post (of 1 total)
- You must be logged in to reply to this topic.
IT, Programming, & Web Development › Forums › CS50’s Introduction to Computer Science by Harvard University on Edx › Week 1: [C] – Data Types, Operators, Conditional Statements, Loops, and Command Line › Incremental hashes per row
#include <cs50.h>
#include <stdio.h>
int main(void)
{
int t = get_int(“no. of bricks “);
for (int i=0; i<t; i++)
{
printf(“#\n”);
}
}
Seeking hints/help regarding formulating a suitable loop that will help print 1 hash in the first line, 2 hashes in the second line, 3 hashes in the third line and so on.
Is there a way to multiply the output with printf command.
On first row, 1x#.
Second row, 2x#
Third row, 3x#.
While printf(“#\n”) taking care of printing 1 hash and moving to next line, is there a way to leverage the printf command with loop to print # twice for second row, and so on?
Reply
https://edstem.org/us/courses/176/discussion/1676837/[learn_press_profile]