Total members 9936 | Gratitudes |It is currently Sun Feb 05, 2012 8:04 pm Login / Join Codemiles


All times are UTC [ DST ]




Post new topic Reply to topic  Quick reply  [ 4 posts ] 
Author Code Snippet
 Code subject: C ++ problems
PostPosted: Thu Apr 09, 2009 3:06 am 
Offline
Newbie
User avatar

Joined: Thu Apr 09, 2009 2:39 am
Posts: 3
Has thanked: 0 time
Have thanks: 0 time

Trying to figure out how to write this program. Its a ..for loop and I never have written one. The loop is suppose to produce some kind of output.

x = 0
cout = 1;
while (cout <=25)
{
x = x-count;
count ++;
}


TOP
 Profile Send private message  
Reply with quote  
 Code subject: Re: C ++ problems
PostPosted: Thu Apr 09, 2009 6:20 pm 
Offline
Newbie
User avatar

Joined: Fri Mar 20, 2009 4:03 am
Posts: 21
Location: Indonesia
Has thanked: 0 time
Have thanks: 0 time
#include<iostream>
using namespace std;

int main() {
int x = 0;
int c = 1;
while (c <=25)
{
x = x - c;
c++;
cout << x << endl;;
}
cin >> x; return 0;
}

I duno if tht is what u meant. Dun use key word like "cout" for variable names...i've modified the program...cek if that's what u want

_________________
***
Miracle's in your hands
***
Do you Love stories? visit this : http://melyablackrose.blogspot.com/. I bet you won't be sorry


TOP
 Profile Send private message  
Reply with quote  
 Code subject: Re: C ++ problems
PostPosted: Wed Oct 27, 2010 11:32 pm 
Offline
Newbie
User avatar

Joined: Wed Oct 27, 2010 11:20 pm
Posts: 2
Has thanked: 0 time
Have thanks: 1 time
to write a for loop
first identify a variable
like int i;
then for(i=0;i<25;i++)//i starting from 0 to <25 means to 24//i++means it is ascending
{
cout<<i<<endl;
}
that code will cout from 0 up to 24
if u want the code descending
for(i=25;i>0;i--)
{
cout<<i<<endl;
}



For this message the author alaa111151 has received gratitude : msi_333
TOP
 Profile Send private message  
Reply with quote  
 Code subject: Re: C ++ problems
PostPosted: Tue Jan 17, 2012 7:54 am 
mestz6 wrote:
Trying to figure out how to write this program. Its a ..for loop and I never have written one. The loop is suppose to produce some kind of output.

x = 0
cout = 1;
while (cout <=25)
{
x = x-count;
count ++;
}


See brother u have declared x as 0 therefore looping condition is x=x-count i.e 0=0-(count).
but for seeing this result u must write a printf statement i.e printf("X= %d",x); OK !
If any problem u have contact me at (shoaib_sayyed49@yahoo.com) I would love to help my brothers.


TOP
  
Reply with quote  
Post new topic Reply to topic Quick reply  [ 4 posts ] 
Quick reply


  


 Similar topics
 Topic title   Forum   Author   Comments 
 Skin customize problems..  PHPbb3 support  Ghostface  1
 Problems since upgrade to 3.0.6  PHPbb3 support  DjDavOnline  3
 Problems - mile200  PHPbb3 support  bady  2
 HELP! Javascript Problems (manual Slideshows), Having troubl  Java  pawani  3
 How Can I Avoid Domain Renewal Problems?  General Discussion  AskBot  3

All times are UTC [ DST ]


Users browsing similar codes

Users browsing this forum: No registered users and 1 guest



Jump to:  
Previous Code Snippet | Next Code Snippet 




Home
General Talks
Finished Projects
Code Library
Games
Tutorials

Java
C/C++
C-sharp
php
Script
JSP/Servlets
Ajax
ASP/ASP.net
Google SEO
Database
Communications
Phpbb3 styles
Photoshop tutorials
Flash tutorials
Find a job






Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team