TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Ken H
NA
646
361k
Print pyramid digit question?
Apr 28 2012 11:42 PM
hi all,
#include<iostream.h>
void main()
{
int p,m,q,n;
cout<<"enter the number of lines:";
cin>>n;
for(p=1;p<=n;p++)//control row
{
//to print spaces
for(q=1;q<=n-p;q++)
cout<<" ";
//to print numbers
m=p;
for(q=1;q<=p;q++)
{
cout.width(4);
cout<<m++;
}
m=m-2;//the "m=m-2" In this role?
for(q=1;q<p;q++)
{
cout.width(4);
cout<<m--;
}
cout<<endl;
}
}
now,I just want to know the role of the variable "m=m-2" in this.
thanks.
Reply
Answers (
2
)
Determine whether to digital in c++
How to find the number of top columns and columns which contains all zero's in a file?