473,326 Members | 2,061 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

same class project need help

i was helped with my project but when i tried to compile it it kept showing me errors and wasn't able to figure it out.

The project is:

Write an original C++ program that will take as input a character and an integer.
If the integer is even, them add one to it.
The output will be a "diamond" composed of the character and as wide as the int.
Example:
Enter a character and an integer:
@ 5

@
@@@
@@@@@
@@@
@

Enter a character and an integer:
$ 6

$
$$$
$$$$$
$$$$$$$
$$$$$
$$$
$

couldn't make it a diamond shape but you get the point.i'll really appreciate it.
Oct 5 '06 #1
3 1591
ltgbau
41
you need include some header files
i don't include here :D

Expand|Select|Wrap|Line Numbers
  1.  void main() 
  2. {
  3. cout<<"Input a character and a integer number:"<<endl;
  4. char ch;
  5.  
  6. int num;
  7.  
  8. cin>>ch>>num;
  9.  
  10. if(num<0)
  11.  
  12. num=1;
  13.  
  14. if(num%2==0)
  15.  
  16. num++;
  17.  
  18. system("cls");
  19.  
  20. for(int i=0; i<num; i++)
  21.  
  22. {
  23.  
  24. if(i<=num/2)
  25.  
  26. {
  27.  
  28. for(int j=0; j<(i*2+1); j++)
  29.  
  30. {
  31.  
  32. cout<<ch;
  33.  
  34. }
  35.  
  36. }
  37.  
  38. else
  39.  
  40. {
  41.  
  42. for(int j=0; j<((num-1-i)*2+1); j++)
  43.  
  44. {
  45.  
  46. cout<<ch;
  47.  
  48. }
  49.  
  50. }
  51.  
  52. cout<<endl;
  53.  
  54. }
  55. }
  56.  
Oct 5 '06 #2
D_C
293 100+
You should have kept this with the other thread. I gave you some code, but not all of it. I left some comments where you need to fill in the blanks. Post the code, and we'll tell you why it doesn't compile, and what you have to do to fix it.
Oct 5 '06 #3
r035198x
13,262 8TB
You should have kept this with the other thread. I gave you some code, but not all of it. I left some comments where you need to fill in the blanks. Post the code, and we'll tell you why it doesn't compile, and what you have to do to fix it.
Or better still try to understand the code you were given.Consult some texts if you have to.
Oct 5 '06 #4

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

Similar topics

2
by: Chi Tang | last post by:
Hi, I have 2 questions: How to call a class member function from another class and these 2 classes are in the same namespace? Also, how to use another project's dialog box and this 2...
0
by: Hemraj Julha | last post by:
Hi (Sorry if this appears twice but I posted this yersterday and I can't see it in the forum today) I'm trying "Visual Inheritance" in C# and facing an issue which might be related to my...
1
by: Hemraj Julha | last post by:
Hi I'm trying "Visual Inheritance" in C# and facing an issue which might be related to my ignorance about namespaces and location of the source code within the folders so I'll try to explain my...
3
by: MajorTom | last post by:
Hello everybody, I need help on how to use the same datase in two different form, this is the scenario: at the first form I load a big dataset (ds1) for short, but I not want to load it again...
6
by: Thomas Connolly | last post by:
I have 2 pages referencing the same codebehind file in my project. Originally the pages referenced separate code behind files. Once I changed the reference to the same file, everything worked...
4
by: Big Dave | last post by:
Good morning. I have a solution set up with multiple projects. One is a web project and it contains my web.config file. I would like to build a class within another project (a class library)...
5
by: Jeremy | last post by:
I have a core VB service that monitors a database, and based on data in the records will execute code to send email notifications. Problem: I don't want my main program code to halt and wait for...
1
by: D Witherspoon | last post by:
Coming up with a scenario here. For example there is the standard .NET MailMessage class. I am creating a project (let's call it CommonBase) that has the following 2 classes ...
6
by: JonathanOrlev | last post by:
Hello everyone, I have a newbe question: In Access (2003) VBA, what is the difference between a Module and a Class Module in the VBA development environment? If I remember correctly, new...
4
by: Alan Mailer | last post by:
Again, I'm new to VB.net and there is something I need help with: Like (I assume) many of us, over time I want to be able to create some VB.net classes that I might want to use in more than one...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.