473,854 Members | 1,498 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ


8 New Member
I have to do two exercises out of my textbook which work fine but I have to display a banner before doing the exercises
//March 19, 2008
//Exercise 5.23 and 5.24
//Project 1

#include <iostream>
using std::cout;
using std::endl;
using std::cin;

int main()
cout<<"Project 1"<<endl;
cout<<"name"<<e ndl;
cout<<"March 19, 2008"<<endl;
cout<<"Computer Science 111-003"<<endl;
cout<<"Exercise 5.23 and 5.24"<<endl;

void print (int any);

int any;
cout<<"Please type in a positive odd integer: ";
while((any%2==0 )||(any<=0));
return (0);
void print(int any)
int spaces=any/1, size=1, counter, count;
for(counter=0;c ounter!=(any+1)/2;counter++){
for(count=space s;count>0;count--)
cout<<" ";
for(count=size; count>0;count--)
for(counter=any/2;counter>0;cou nter--){
for(count=0;cou nt!=spaces;coun t++)
cout<<" ";
for(count=size; count>0;count--)

system ("PAUSE");

Mar 17 '08 #1
1 7275
28 New Member
Expand|Select|Wrap|Line Numbers
  1. //March 19, 2008
  2. //Exercise 5.23 and 5.24
  3. //Project 1
  7. #include <iostream>
  8. using std::cout;
  9. using std::endl;
  10. using std::cin;
  12. int main()
  13. {
  14. cout<<"Project 1"<<endl;
  15. cout<<"name"<<endl;
  16. cout<<"March 19, 2008"<<endl;
  17. cout<<"Computer Science 111-003"<<endl;
  18. cout<<"Exercise 5.23 and 5.24"<<endl;
  19. cout<<endl;
  28. void print (int any);
  31.     int any;
  32.     do{
  33.         cout<<"Please type in a positive odd integer: ";
  34.         cin>>any;
  35.     while((any%2==0)||(any<=0));
  36.     print(any);
  37.     return (0);
  38. }
  39. void print(int any)
  40. {
  41.     int spaces=any/1, size=1, counter, count;
  42.     for(counter=0;counter!=(any+1)/2;counter++){
  43.         for(count=spaces;count>0;count--)
  44.             cout<<" ";
  45.         spaces--;
  46.         for(count=size;count>0;count--)
  47.             cout<<"*";
  48.         size+=2;
  49.         cout<<endl;
  50. }
  51. size=any-2;
  52. spaces+=2;
  53. for(counter=any/2;counter>0;counter--){
  54.     for(count=0;count!=spaces;count++)
  55.         cout<<" ";
  56.     spaces++;
  57.     for(count=size;count>0;count--)
  58.         cout<<"*";
  59.     size-=2;
  60.     cout<<endl;
  61.     }
  63. system ("PAUSE");
  65. }
To start with you can't define a function within a function. Try pulling this outside the main function, that might give you an ide of where the problems with your code are.

Until you really know what you are doing always wrap if statements and for / while loops in '{}' brackets; although you don't need them they make it harder for you to make mistakes and the make it easier for other people to read you code. In your case I'm not really sure where one function is supposed to start and the other end, for example;
Expand|Select|Wrap|Line Numbers
  1. size=any-2;
  2. spaces+=2;
  3. for(counter=any/2;counter>0;counter--){
  4.     for(count=0;count!=spaces;count++)
  5.         cout<<" ";
  6.     spaces++;
  7.     for(count=size;count>0;count--)
  8.         cout<<"*";
  9.     size-=2;
  10.     cout<<endl;
  11.     }
  13. system ("PAUSE");
  15. }
Isn't part of any function
Mar 17 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

by: FS | last post by:
where is it that you are adding the code for the banner to pop up nex to your logo? Ive tried adding the image in the banners section to n avail. Any thoughts http://eye.cc -php- web design
by: Ron Lounsbury | last post by:
We have 2 copies of our web application - Development and Checkout. We have noticed that when the QA quys go through our QA version, they will sometimes find that pages are missing the banners. The banners are created by VI using the themes and layouts. All of the other theme/layout information is fine, and both sites are using identical Site Diagrams. We have even tried copying the site diagram over from development to QA again and...
by: Andy Dingley | last post by:
http://www.glasgowsurvival.co.uk/weapons/glaWeapons.html I liked this page too: http://www.glasgowsurvival.co.uk/gallery/glaNedGal.html Piccies and piccies of neds (scallies in my local argot) Then down at the bottom there's an "XHTML valid" icon. Glasgow - got to love it (or else they'll chib ye)
by: Terry Haufler | last post by:
I am trying to swap/rotate random flash banners using the following Javascript code. I have 3 flash headers/banners. I can get it to open a page with a random header using document.write(randomHeader) in the chooseHeader() function, but the rest of the page doesn't get displayed with that approach. Instead, what I would like to do is comment the document.write(randomHeader) line, and use the random reference I have in the table cell...
by: Jimmy | last post by:
In the asp.net application I develop, we need to provide the marketing department with the ability to insert small JavaScript code snippets into predefined content areas on several pages. This code is supplied from 3rd parties and may display banners, links and do various other things. So far so good. What I need is to track the clicks for each such banner in a generic way. That is, whatever JS provided has to run inside some control (or...
by: Jimmy | last post by:
In the web application I develop, we need to provide the marketing department with the ability to insert small JavaScript code snippets into predefined content areas on several pages. This code is supplied from 3rd parties and may display banners, links and do various other things. So far so good. What I need is to track the clicks for each such banner in a generic way. That is, some javascript or server-side technique that will allow...
by: Crash44 | last post by:
This is driving me quite nuts. I have created several flash banners for a record label. They are meant to link to an artist splash page. Simple enough, right? Both Mac and PC users can click on these banners on my corporate client page, and anywhere else on the web for that matter, but the banners don't work for Mac users on Myspace - just Mac users. They can see the banner. the banner animates as it should, but clicking the banner produces...
by: torquehero | last post by:
Hi.... I am looking for some really good web banners for my Website. I am a designer but havent worked much with websites. So I would really appreciate it if anybody could give me some references about good websites or sites where I can find good banner designs... Thanx :D Regards ToRqUE
by: blaqpig | last post by:
ok not sure how to go about this but what is the best possible way to make a site but also make room for banners. Should each banner (160x600, etc) be put in its own table down the left lets say. Main content (800px) down the center) and maybe a 100px banner to the right. The way I imagine it is to have 3 tables all set at those widths and I can keep expanding underneath? I ask because as main content expands (in the middle) I did not...
by: jock1up | last post by:
I am working with javascript...where I have cycling banners at the top, 3 of them and I need to make two of them clickable to a website that I assign to the two. bannerad2 for www.bigmtn.com and bannerad3 for www.bridgerbowl.com Not sure how to get this to work right, have tried some things and it usually ends up making duplicate banners above the original, which I don't want. Here is some of the code for now: <html> <head> <title>Ski...
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.