Forum     

Go Back   Digit Technology Discussion Forum > Software > Programming
Register FAQ Calendar Mark Forums Read

Programming The destination for developers - C, C++, Java, Python and the lot


Closed Thread
 
LinkBack Thread Tools Display Modes
Old 16-03-2008, 10:36 PM   #1 (permalink)
Genius in making mistakes
 
bhushan05d251's Avatar
 
Join Date: Dec 2006
Location: Mumbai
Posts: 521
Default need following output in c++


0.JPG
bhushan05d251 is offline  
Advertisements. Register and be a member of the community to get rid of them.
Advertisement

Old 16-03-2008, 11:24 PM   #2 (permalink)
Commander in Chief
 
QwertyManiac's Avatar
 
Join Date: Jul 2005
Posts: 6,658
Default Re: need following output in c++

I hate triangles. Why on earth do schools give so much of these crap as homework I'll never know. Loops can be learned in better ways!

Code:
#include <iostream>

using namespace std;

int main(void)
{
	int i(0),j(0),n(0);
	int index(1);
	cout<<"Enter no. of rows: ";
	cin>>n;
	for(i=1;i<n+1;i++)
	{
		for(j=1;j<n-i+1;j++)
		{
			cout<<" ";
		}
		for(j=1;j<i+1;j++)
		{
			cout<<i<<" ";
		}
		cout<<endl;
	}
	cout<<endl;
	//End of Program 1
	for(i=0;i<n;i++)
	{
		//Weird space indent in 2nd right triangle. Still...
		for(j=0;j<5;j++)
		{
			cout<<" ";
		}
		for(j=0;j<i+1;j++)
		{
			cout<<(index%10);
			index++;
		}
		cout<<endl;
	}
	cout<<endl;
	//End of Program 2
	for(i=1;i<n+1;i++)
	{
		for(j=1;j<n-i+1;j++)
		{
			cout<<" ";
		}
		for(j=i;j>0;j--)
		{
			cout<<(j&1);
		}
		cout<<endl;
	}
	//End of Program 3, your second right angle.
	return 0;
}
And for your TurboCrap's (a.k.a Turbo C/C++) sake, just and another #include <conio.h> and a getch(); before return 0; at end.
__________________
Harsh J
www.harshj.com

Last edited by QwertyManiac; 16-03-2008 at 11:28 PM. Reason: Improved efficiency and removed unnecessary increments.
QwertyManiac is offline  
Old 16-03-2008, 11:53 PM   #3 (permalink)
Genius in making mistakes
 
bhushan05d251's Avatar
 
Join Date: Dec 2006
Location: Mumbai
Posts: 521
Default Re: need following output in c++

thnx man.....u r gr8.....never forget ur hlp.....
bhushan05d251 is offline  
Old 17-03-2008, 12:17 AM   #4 (permalink)
Commander in Chief
 
QwertyManiac's Avatar
 
Join Date: Jul 2005
Posts: 6,658
Default Re: need following output in c++

You, in fact, have already done what you had said you won't do and you are still mostly oblivious to how this code functions and have just smacked it all down onto paper, ready for submission or to move along to the next chapter post memorizing it.

All this holds true with a P = 0.96.
__________________
Harsh J
www.harshj.com
QwertyManiac is offline  
Old 20-03-2008, 05:16 PM   #5 (permalink)
Apprentice
 
radonryder's Avatar
 
Join Date: Dec 2006
Posts: 72
Default Re: need following output in c++

@QwertyManiac
They give you guys comp homework????
__________________
I have created over a thousand blades.Unknown to death.Nor to life.Have withstood pain to create many weapons.Yet,those hands will never hold anything.so i pray,"Unlimited Blade Works"
radonryder is offline  
Old 20-03-2008, 06:33 PM   #6 (permalink)
Commander in Chief
 
QwertyManiac's Avatar
 
Join Date: Jul 2005
Posts: 6,658
Default Re: need following output in c++

No they never did give me those, but 0.85 of all these queries of "need program" are all mere homework or assignments of people.

Am glad to do something if I have the free time but its the OP at loss, as always.
__________________
Harsh J
www.harshj.com
QwertyManiac is offline  
Old 20-03-2008, 07:38 PM   #7 (permalink)
18 Till I Die............
 
Join Date: Jul 2004
Location: India, Mumbai, Marine Lines
Posts: 5,792
Default Re: need following output in c++

And you learn more of probability, side by side.
__________________
http://www.bash.org/?258908
mehulved is offline  
Old 22-03-2008, 06:48 PM   #8 (permalink)
Commander in Chief
 
QwertyManiac's Avatar
 
Join Date: Jul 2005
Posts: 6,658
Default Re: need following output in c++

Hehe that too.
__________________
Harsh J
www.harshj.com
QwertyManiac is offline  
Closed Thread

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
5.1 output........Please HELP ! ! ! zany QnA (read only) 48 20-03-2009 06:51 PM
Output Screen In C++ ! BBThumbHealer Programming 7 08-03-2009 06:10 PM
Problem with TV output. slash_89 Hardware Q&A 1 03-05-2007 06:55 PM
TV & DVI output problem god_of_frauds Hardware Q&A 3 25-12-2005 10:30 PM
C- Printing output godsownman QnA (read only) 4 21-09-2005 10:23 PM

 
Latest Threads
- by Charan
- by Sarath
- by clmlbx

Advertisement




All times are GMT +5.5. The time now is 12:54 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.

Search Engine Optimization by vBSEO 3.3.2