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:
*****
****
***
**
*
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.
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.
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;
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.
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)
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.
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)
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 "*".
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.
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
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: 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:");
#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.
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.
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;