C++ :: Print Out Square Of Stars With Different Length And Width Given?

Feb 27, 2013

#include <iostream>
using namespace std;
int main()
{

[Code].....

how do i change this code to accept two numbers from the user and print it as the different length and widtth? it has to be a for loop as well.[code]

View 5 Replies


ADVERTISEMENT

C++ :: Input Length / Width And Height For 3 Boxes - Sum And Average Volume

Dec 6, 2013

How would I make it so that I can have someone input the length, width and height for all 3 boxes and then have it output the sum and average volume? Here's an example of what I would like:

INPUT - Enter Box 1 (Length, Width, Height): 10.1 11.2 3.3
INPUT – Enter Box 2 (Length, Width, Height): 5.5 6.6 7.7
INPUT – Enter Box 3 (Length, Width, Height): 4.0 5.0 8.0
OUTPUT – The sum of the volume is 812.806
OUTPUT – The average volume is 270.935

Here's my original code:

#include <iostream>
using namespace std;
double box(double length, double width, double height); // use double data
int main() {
double sum;
sum = box(10.1, 11.2, 3.3) + box(5.5, 6.6, 7.7) + box(4.0, 5.0, 8.0);

[Code] .....

View 1 Replies View Related

C++ :: Input Number And Print Out Same With Stars In Between

Apr 16, 2013

Basically i want to input a number for example 123456 and get back how many 7's are in the input number and also to print out that same number with stars in between like this *1*2*3*4*5*6*. Here is what i have so far:

#include <iostream>
using namespace std;
int countSeven(int x){
if(x == 7)return 1;
int c = 0;
while(x/10 > 9)c++;
return countSeven(x/10)+1;

when i compile it does not do what i tell it it just tells me there are 0 7's in the input number no matter how many there really are...

View 9 Replies View Related

C++ :: Print Stars Function In 1D Array?

May 2, 2014

I'm having trouble with my for loop near the end of the program was able to print everything else.

Sample Output:

*** end of 27610_Arrays04.cpp program ***

City City Points
--------------- 1---5----10---15---20
Belvidere **********
Freeport ********
Byron ************
Stillman Valley ***************
Rockford *********

*** end of 27610_Arrays04.cpp program ***

Input:

TODO #1: complete the coding of the points array
An integer array of 5 numbers: 10, 8, 12, 15, 9

TODO #2: complete the coding of the cities string array
An string of 5 city names intialized to:
"Belvidere", "Freeport", "Byron", "Stillman Valley", "Rockford"

Compile-time arrays with initialization lists.

Processing & Output:

TODO #3: complete the coding of the call to the printStars() function

TODO #4: code the printStars() function

#include <iostream>
#include <iomanip>
#include <string>
using namespace std;
int main(void) {
/* declarations ------------------------------------------------*/

[Code] ....

View 2 Replies View Related

C++ ::  Vertical Histogram - Variables In For Loop To Print Stars

Dec 6, 2013

I want to create a vertical histogram in my code. I already made it go vertical but not the way I want it.

Example:
I want it like this:

Range1 Range2 Range3 Range4

And asterisks under each one, depending on the user input. (My code is below and doing it on here doesn't make it come out correctly)

But what I've managed to do is this:

Range1
*
*
*

Range2
*
*

Range3
*
*
*
*

Range4
*
*

Which I don't want. I want everything else to stay pretty much the same since I can only use some features such as Arrays and really basic functions.

Here is my code: (Worked fine last time I used it and I am doing it on Visual Studio 2010 (at uni) and 2013 (on my laptop)).

#include <iostream> //Start of code
using namespace std;
int MarkValueInput; //Mark entered by user
//Counter variables for ranges in While Loop
int counterlow; //Counter for low range
int countermidlow; //Counter for mid-low range
int countermidhigh; //Counter for mid-high range
int counterhigh; //Counter for high range

[Code] .....

View 4 Replies View Related

C++ :: Print Stars Function - Corresponding To Array Index Size

Nov 24, 2014

I am having trouble getting the stars to output correctly in the printStars function. the final output should look something like this:

#include <iostream>
using namespace std;
int readArray(int input[], int size);
void printArray(int input[], int count);
void printStars(int input[], int size);

[Code] ...

View 3 Replies View Related

C++ :: Print Square Roots Of Numbers With Rows And Columns

Mar 12, 2013

this is what i have so far

#include <iostream>
#include <cmath>
using namespace std;
int main () {
int v;

[Code] ....

im trying to get the program to print this as an example if the user enters 5 (the rounding of the decimal is optional).

1 1.41 1.73 2 2.24
1 1.41 1.73 2
1 1.41 1.73
1 1.41
1

why its not reading my for loop for rows its only doing columns ...

View 4 Replies View Related

C :: Program To Print The Length Of A String

Oct 20, 2013

Well what the title says, but I can't get it done. This is what I got

Code:
#include <stdio.h>#include <string.h>
int main(void)
{
char word;
int count;
printf("Enter a word.

[Code] ....

View 4 Replies View Related

C :: Print All Pythagorean Triples With Length Of Hypotenuse

Oct 2, 2014

So this is a programming assignment right now that I'm working on. I was able to satisfy two or the requirements: to print all Pythagorean triples with the length of the hypotenuse being below the entered value and to state how many Pythagorean triples there are. I've come into a problem, though, since the final requirement is to state the largest Pythagorean triple. The problem is that it posts the values of a,b,c after the loop exits, which are going to be the values right below N (eg. N=19, then a,b,c=16,17,18).

Here is the program:

Code:
#include <stdio.h>
void main () {
int a,b,c,N;
int ctr = 0;

[Code] ....

My questions is how to fix this problem because putting it in the for loop will just cause it to repeat all values.

View 4 Replies View Related

C/C++ :: Displaying Filled Square Next To Hollow Square?

Feb 28, 2015

I am able to display a filled and hollow square by themselves, but I can't seem to be able to get them side by side.

So this is my code so far:

[/
#include <iostream>
using namespace std;
int main()

[Code]....

I can get the hollow square to show up, but the first square just shows up as a single line instead of a square. It seems that it ignores the first if statement in the second loop. I've tried not using an if statement in the second loop but it didn't seem to work either.

View 4 Replies View Related

C++ :: Draw A Square Within A Square Pattern

Oct 25, 2013

I know how to draw a square hollow or filled but i need to draw an alternating pattern ....

ex
iPatternHeight = 1
X

iPatternHeight = 3
OOO
OXO
OOO

[Code] .....

View 6 Replies View Related

C :: Declared A String Constant And Trying To Print Length Of String

Oct 9, 2014

In this code, i declared a string constant and trying to print the length of string. I know that if i write char a1[7] or char a1[] than it runs and give aggregate output, but in this case it is giving double length of string.

Code:

#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
}

[code]....

View 5 Replies View Related

Visual C++ :: Program That Count From 1 To 12 And Print Count And Its Square For Each Count

Dec 16, 2014

4.1 Write a program that will count from 1 to 12 and print the count, and its square, for each count.

4.2 Write a program that counts from 1 to 12 and prints the count and its inversion to 5 decimal places for each count. This will require a floating point number.

4.3 Write a program that will count from 1 to 100 and print only those values between 32 and 39, one to a line. Use the incrementing operator for this program.

View 2 Replies View Related

C# :: How To Draw A Square Within A Square

Oct 25, 2013

I know how to draw a square hollow or filled but I need to draw an alternating pattern

ex
iPatternHeight = 1
X

iPatternHeight = 3
OOO
OXO
OOO

[Code] ......

View 2 Replies View Related

C++ :: Pyramid Of Stars With Spaces

Mar 21, 2013

How to solve this (for cycle)?

View 12 Replies View Related

C++ :: Star Pyramid Program - Adding Stars?

Sep 13, 2013

I have written a star pyramid program, it adds two stars at a time but I want to rewrite the program so the stars double each time.

#include<iostream>
using namespace std;
int main() {
int a = 0, b = 8;
for (int c = 1; c < 10; c++) {
for (int space = b; space > 0; space--)

[Code] ...

View 1 Replies View Related

C++ :: Construct A Program Without Main Function That Output Stars

Nov 5, 2013

I am trying to construct a program without a main function that outputs stars but at the same time outputs the number and a colon after the number but before the number of star. This is the coding i have so far.

void output_stars(int num){
if (num > 0){
cout << "*";
output_stars(num-1)

[Code] ....

The program is working the way it should i just can't figure out how to output the number and a colon. The main function is written as such:

output_stars(1);
output_stars(2);
output_stars(5);
output_stars(3);
output_stars(4);
output_stars(7);

How to get the numbers of the main function to show up with the stars of the previous function.

View 6 Replies View Related

C :: Strcpy - How To Update Old String In Stars Array With New That Includes Correct Letters

Apr 25, 2013

This for loop replaces the stars ******** in an array that contains a word to be guessed with the correct letter (c) that the user inputs if the word contains that letter.

Problem: After every guess the same hidden string of stars ******* is displayed instead of ex: ***W**** (assuming W was entered by the user)

How can I update the old ******** string in the Stars array with the new string that includes the correct letters chosen, so after every correct guess at a letter in the word a new string is displayed including the correct letters chosen?

I'm pretty sure I have to use strcpy but not sure how to implement it using a loop.

Code:
for(i = 0; i < strlen(unscrambledWord); i++) {
if(unscrambledWord [i] == c) {
Stars[i] = c;
} }

View 1 Replies View Related

C :: Making A Parallelogram That Prints 5 Stars And A Line Break With Increasing Spaces

Sep 12, 2013

All I have so far is a rectangle that prints 5 stars in length and 20 lines in length. What I want to do now is have each new line print an extra space more than the line before it and then print 5 stars.. This is what I have so far:

Code:

#include <stdio.h>
int main (void){
int i;
for(i=1; i<=20; i++){
printf("*****
");

[code]....

View 1 Replies View Related

C++ :: Variable (Width) Is Being Used Without Initialized

Mar 14, 2013

It said my width1 is being used wihtout being initialized.. what does it mean?

#include<iostream>
using namespace std;

double Area(double height, double width);
double Perimeter(double height, double width, double height1, double width1);

[Code] .....

View 2 Replies View Related

C :: Width Specifier Does Not Align Like In Printf

Apr 19, 2013

I am currently debugging this function. I am trying to make this function's width specifier align like a printf() routine. Here 's the code:

v Code:
oid
bu_log(const char *fmt, ...) {
va_list ap;
struct bu_vls output = BU_VLS_INIT_ZERO;

if (UNLIKELY(!fmt || strlen(fmt) == 0)) {
bu_vls_free(&output);

[Code] ....

View 8 Replies View Related

C# :: Width And Height For Column And Rows

Mar 21, 2014

Basically when I type in different widths and heights for the col and rows, the buttons that make up the width get cut off. Something is messed up but I'm not sure what!

InitializeComponent();
int _col = int.Parse(cols);
int _row = int.Parse(rows);
int width = groupBox1.Width;
int height = groupBox1.Height;
int bW = width / _col;
int bH = height / _row;

[Code] ....

View 4 Replies View Related

C# :: Extending The Width Of The Labels To Specific Value?

Jun 3, 2014

The program is when a person clicks a button this button updates 2 separate listbox one tracks the total rolls the other displays the total amounts of frequency afterwards adjusting labels as a scaling measurement.

The problem I am having is right at the end where I am trying to adjust the width of the label this is what I have. It is highlighting the word "Items" for each label and says that Non-Invokable member 'System.Windows.Forms.ListBox.Items' Cannot be used like a method L2 is a label. Additionally I have added in the information for one of my loops below the line I am having trouble with this loop is created to determine how many lines are in the listbox of rolls and I have no trouble with this just thought id add it for additional information I dont think I need to add the rest of the code but I can if needed.

L2.Width = int.Parse(lstfrequency.Items(0).ToString());
TL = 0;
for (I = 0; I <= 10; I++)
{
TL += int.Parse(lstfrequency.Items[I].ToString());
}
lstfrequency.Items.Add(TL);

View 9 Replies View Related

C/C++ :: How To Use Rectangle Height And Width In Functions

May 13, 2014

The problem says:

Define functions n(), s(), e(), w(), center(), ne(), se(), sw() and nw(). Each takes a Rectangle argument and returns a Point. These functions define connection points on and in the rectangle. For example, nw® is the northwest (top-left corner) of a rectangle called r.

I wrote below code for that:

#include <Simple_window.h>
Point n(const Graph_lib::Rectangle& r);
Point s(const Graph_lib::Rectangle& r);
Point e(const Graph_lib::Rectangle& r);
Point w(const Graph_lib::Rectangle& r);
Point ne(const Graph_lib::Rectangle& r);
Point se(const Graph_lib::Rectangle& r);

[Code]...

As you see, this just mark the top-left corner of the rectangle r. In other functions I need the specifications of that rectangle, for example its height and width. How to use these specs in those functions?

View 2 Replies View Related

C Sharp :: Graphic Pen 1 Sided Width?

Apr 28, 2012

I am drawing two circle (inner circle and outer circle) using DrawElipse method. I have created two pen object named OuterPen and InnerPen and creating Outer Circle using OuterPen and Inner Circle using InnerPen. Problem that I am facing is that when I increase the size of outer pen lets say 10px then it overlaps the inner circle and inner circle is hide. How can I increase the size of OuterPen outwards and not inwards so that it don't overlap the inner circle?

View 3 Replies View Related

Visual C++ :: Width And Height From HBITMAP?

Sep 5, 2013

If I get a bitmap from the clipboard with:

hBitmap=(HBITMAP)GetClipboardData(CF_BITMAP);

...how do I get the width and height ? Can I get at the BITMAPINFO ?

View 2 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved