Click here to Skip to main content
15,867,308 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Write a program that asks the user for a positive integer N. The program then displays N stars on the screen (one star per line). You are required to use a for loop.
Posted
Comments
Sergey Alexandrovich Kryukov 21-Oct-15 0:37am    
The question in the title is a question about nothing, and the body of it is not a question at all. Is it a request to do your job for you?
—SA

Pick up a book and learn the concepts of programming.
It will help you as you try and write programs and learn about programming.
 
Share this answer
 
Comments
Patrice T 21-Oct-15 2:12am    
+5
Abhinav S 21-Oct-15 10:16am    
Thanks.
C++
#include <iostream>
#include<conio.h>
#include<stdlib.h>
using namespace std;
int main()
{

    int N,i;
    system("cls");
    cout<<"enter the no of rows to be printed";
    cin>>N;
    for(i=1;i<=N;i++)
    {
        cout<<"*\n";
    }
    getch();
}

Kindly note that when you work on an old compiler just replace #include<iostream> to #include<iostream.h> and remove using namespace std.Here I have declared two variables N and i.The variable N is declared and used to ask the user for a positive integer as per your question.And the variable i is used in the execution of for loop till the user's condition satisfies.Please note the an escape sequence \n is very much important because it satisfies your question completely.
 
Share this answer
 
v4

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900