Plese solve this problem.
Using nested for loop print the following
*******
*****
***
*
Plese solve this problem.
Using nested for loop print the following
*******
*****
***
*
hellp kro yar kahan gum ho gy it dunya members.
int stars = 7;
for(int i = 0; i < 4; i++){ //Main loop for printing stars in 4 lines
while(stars > 1){ // this loop will print the whole line
cout << "* ";
stars--; //decrement with one
stars--; // decrement with one or use (stars = stars-2)
}
cout << endl; //jump to the next line
}
Here is my Solution!!!Try it in VISUAL STUDIO!!!
#include "stdafx.h"
#include<iostream>
using namespace std;
void main()
{
int i,j;
for(i=1;i<=7;i++) //Outer loop which is controlling loop
{
for(j=i;j<=7;j++) //Inner Loop which is operational loop
cout<<"*";
cout<<endl;
}
system("pause");
}
moved from Courses > C++.
~* W@R T!ll D3@t|-| *~
~* I'll Win Not Immediately But Definitely *~
heres solution dear brother
#include<iostream.h>
#include<conio.h>
void main()
{
for(int i=7;i>=0;i--)
{
for(int j=i;j>=0;j--)
cout<<"*";
cout<<endl;
}
getch();
}
[FONT="Comic Sans MS"][CENTER][SIZE="5"][B][COLOR="MediumTurquoise"]"The nicest people tend to often be the ones who have been mistreated the most."[/COLOR][/B][/SIZE][/CENTER][/FONT]
#include <iostream.h>
#include <conio.h>
void main()
{
int a,b;
clrscr();
for(a=7;a>=1;a--)
{
for(b=1;b<=a; b++)
{
cout << "*";
}
cout <<"\n";
a=a-1; //for removing 2,4 and 6
}
getch();
}
Bookmarks