C++ :: Printing Out Two Patterns Of Asterisks?
Nov 12, 2013
Write a program that asks the user to enter an integer between 1 and 15. If the number entered is outside that range, your program should print out an error message and re-prompt for another number.
Once the user enters a number in the correct range, your program will print out two patterns of asterisks that look like the following. Note that the number provided by the user is equal to the height of the pattern.
Let us say that the input value was 5. Then please print the following two patterns:
*****
****
***
**
*
[Code].....
View 9 Replies
ADVERTISEMENT
Dec 15, 2014
I have to make a program that displays a square of asterisks based on the users input. Here is what I have so far.
#include<iostream>
using namespace std;
int main(){
int number;
cout << "Enter a number: ";
cin >> number;
for (int i = 0; i < number; i++){
[Code] ....
But the square needs to be hollow like this. So if the user enters 5 then the following square will be shown.
*****
* *
* *
* *
*****
How to make it do this.
View 11 Replies
View Related
Feb 21, 2014
How to print such list of asterisks using a for loops. There are a total of n lines, n is a variable.
View 3 Replies
View Related
Jan 27, 2015
So I have to create a program which will print, among other things, a rectangle made of asterisks. The rectangle has to follow this general format:
*****
* *
*****
but with the width and length of the rectangle being set by the user. I've tried every way I can think of to work this out, but I can't seem to get anything to work. The main errors I'm getting are either an infinite loop of asterisks filling my screen or nothing at all, depending on whether I use an && comparison or ||. A screenshot of my code is included below.
View 5 Replies
View Related
Apr 11, 2015
I have a code for random numbers between 0 and 90 but i can't figure out how to change the output for numbers to asterisks. Ex. if the random number is 8 i need it to print 8 asterisks.
#include <stdio.h>
#include <time.h>
#define MINR 0
[Code].....
View 7 Replies
View Related
Jan 30, 2015
I am new to C and am unfortunately racking my brain against this simple assignment. I believe the task is to produce a rectangle out of asterisks using while loops, yet I can only produce an "L" shape. We were given a code, with syntax errors included.We are to correct the errors and test.
Code:
#include <stdio.h>
/*Houghton, Micah*/
/*ET2560 - Cordova*/
/*Unit 5 Lab - Programming Loops*/
int main(void) {
int length, width;
int lcount, wcount;
[code]....
View 3 Replies
View Related
Mar 16, 2014
i have to make two functions one recursion that ask the user to enter number of rows and i use recursion to tell him how many pins there are ex. user enters 5 there are 15 pins. I did this function now i need a function that prints an asterisk triangle for my recursion function so for 15 it should look like this
*
* *
* * *
* * * *
* * * * *
i tried many times but can't make it descend like that i can only get like a right triangle..the hard part is that it goes with the users number so if they enter 3 for example it should be 3 rows.
int pins(int n){
if(n==0){
return 0;
[code]....
View 1 Replies
View Related
Feb 22, 2013
how can i print an equilateral triangle with asterisks .
View 3 Replies
View Related
Nov 14, 2014
I have been stuck at a dead end,I got it to display a single asterik for an inputted number, but how would i go about in adding that asterik for each number?
my code is the following
int userinput = int.Parse(InputOutput.GetInput("Enter values into array"));
Int32[] inputChoices = new Int32[9];
for (int x = 0; x < inputChoices.Length; x++) {
inputChoices[x] = 0;
} if (userinput == 1)
[Code]...
View 2 Replies
View Related
Sep 6, 2014
I have been tasked with making a diamond out of asterisks based on a given odd integer input. For some reason the bottom half of my diamond will not print. I'm not sure as to why.
Here is my code:
#include "stdafx.h"
#include <iomanip>
#include <iostream>
using namespace std;
int _tmain(int argc, _TCHAR* argv[]){
[Code] ....
View 2 Replies
View Related
Apr 20, 2015
Im trying to figure out how to print a random number of asterisks on two separate lines at the same time. So every time you press a key it prints a different amount of random number of integers between1 and 10 until one of the lines reaches 70. I have the code to do one line but can't figure out how to do two at once.
#include <stdio.h>
#include <time.h>
#define MINR 1
#define MAXR 70
#define MINM 1
#define MAXM 10
int main (void)
[Code]...
View 2 Replies
View Related
Jan 15, 2015
#include <iostream>
using namespace std;
int main(){
return 0;
}
this is my main functions. I have problem making a program that prints in asterisks an oval, arrow and a diamond using for loop and if statements.
View 1 Replies
View Related
Apr 12, 2015
I need to create a program that prints a certain number of asterisks based on user input. The user inputs 5 and I want my program to output "*****". How would I do this in C? I've tried printf("%#**", myvariable) but this does not work it only prints "*".
View 1 Replies
View Related
Oct 7, 2013
What the heck is wrong with my logic? I just print a rectangle!!! I have played with thing for ever it seems. I thought the rotating part would be hard but now I find myself stuck.
Code:
#include <istream>
#include "triangle.h"
using namespace std;
void triangle::create_triangle() {
[Code] ....
View 13 Replies
View Related
Feb 8, 2014
I need c source that give the url txt file and print the txt file
(get the http://site.com/text.txt) and print the (text.txt) file Content.
View 1 Replies
View Related
Nov 21, 2013
I have an array, ary[size+1] and the original values entered and then another value, x, entered. I found the index of x that makes the array nondecreasing order
Code:
void InsertX (int ary[], int size, int x)
{
int i=0;
int j;
int index;
while(ary[i]<x)
[Code]...
But i can't figure out how to print the new array with x in it, using its index
View 6 Replies
View Related
May 8, 2013
how to print a box using 2d arrrays. i have to create a tetris game which a im stuck at this stage... so far i have tired i can only come out with this..my coding done so far is as follows:
Code:
#include <stdio.h>
#define ROW 15
#define COLUMN 15
void disp_box (char b[ROW][COLUMN])
}
[code]....
View 2 Replies
View Related
Mar 9, 2013
I expected this program to print out:
Code: Enter your desired monthly salary: $2000___
Gee! $2000.00 a month is $24000.00 a year. Instead, it printed out:
Code: Enter your desired monthly salary: $2000___
Gee! $2000.00 a month is $24000.00 a year. I don't understand how it got the extra nextline in the middle.
Here is the code:
Code:
#include <stdio.h>
int main(void) {
float salary;
printf("aEnter your desired monthly salary:");
[Code].....
View 2 Replies
View Related
Feb 17, 2015
#include <iostream>
#include <string>
using namespace std;
struct studentType {
string name;
double gpa;
[Code] .....
View 11 Replies
View Related
May 17, 2013
#include <iostream>
using std::cout;
using std::cin;
using std::endl;
using std::ios;
#include "Course.h"
#include <list>
[Code] ....
The program works well, except for the fact when it prints out the list (starting at the for-loop on line 65) each line is the same as the last, like it overwrites itself every time it traverses the while(true) loop.
View 9 Replies
View Related
Aug 13, 2014
I have previous threads asking how to make a list of words that were matched up be printed out into a .css or .txt
Is there anyway to make the words being printed out in CMD after debugging/compiling a script printed out in a .txt/.cpp file instead? CMD only has 300 lines. I need the outcome to be printed out elsewhere so more lines can be posted rather than 300.
View 8 Replies
View Related
Mar 9, 2014
A simple UNIX shell that supports some built-in commands, external commands, and file redirection.
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <unistd.h>
[Code]....
View 6 Replies
View Related
Mar 22, 2015
I've got this assignment where I have to print every other number from 1 to 10.
so far I've got this.
#include <iostream>
using namespace std;
int main() {
[Code].....
wondering if its really counting from 1 to 10 and only printing every other number.
View 9 Replies
View Related
Feb 3, 2014
I am writing a program that takes the Month, Day, and Year inputted from the user and outputs the day of the week (Ex. "February 2, 2014 falls on a Sunday"). I got it to print out the date but I can't figure out how to output the day. Would I be using the ctime function?
#include <iostream>
#include <string>
using namespace std;
[Code].....
View 1 Replies
View Related
Nov 3, 2013
I'm working on a program that prints every even number from 100 to 200. How i would be able to print 10 numbers per line?
Code:
#include <iostream>
using namespace std;
int main()
{
int x;
for (x=100; x<=200; x++)
cout <<x++<< endl;
system("pause");
return 0;
}
View 2 Replies
View Related
Feb 1, 2014
It only prints out the root in an infinite loop.
Code: void Btree::printTree(Node* tree)
{
tree=root;
if (tree != NULL)
{
std::cout<<" "<< tree->key;
printTree(tree->left);
printTree(tree->right);
}
}
View 5 Replies
View Related