C :: Produce A Rectangle Out Of Asterisks Using While Loops

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


ADVERTISEMENT

C++ :: Extracting From Loops - Run X Number Of Times And Produce A Prize Each Time

Sep 19, 2013

so i have a loop that will run x number of times and each time it will produce a prize which is a certain sum of money. I need to a way to sum all the money earned. I am thinking there should be a way to extract the prize one for each time the loop runs but i am not sure how to do that.

#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
using namespace std;

int main() {
cout <<"Option A: Drop one chip into one slot" << endl;

[Code] .....

View 2 Replies View Related

C :: Printing A Rectangle Using For Loops?

Jan 27, 2015

I'm trying to make a program that prints a rectangle using "*" asterisks. I am only allowed to use "for loops" and I simply cannot get this to work properly. Here is my code so far...

Code:
int main(void)
{
//RectangleSize represents the area of the rectangle(width*length)
int length, width, RectangleSize;

[Code].....

View 5 Replies View Related

C/C++ :: Drawing A Rectangle Using ASCII Code And For Loops?

Apr 24, 2015

For a Texas holdem' project I need to be able to draw out rectangles using ASCII codes and for loops. I started the code

#include <iostream>
#include <string>
#include <Windows.h>

[Code].....

View 6 Replies View Related

C++ :: Send Rectangle To A Function Which Takes A Rectangle Argument

May 13, 2014

Consider I have a rectangle like this:

Point p1(100,100);
Point p2(300,200);
Graph_lib::Rectangle r(p1,p2);

And also I have a function that takes a rectangle and returns a Point of that, say, top-left corner of that rectangle. For example:

Point N(Graph_lib::Rectangle R1);

My question is that, first, how to send that Rectangle r(p1,p2) to the Point N(Graph_lib::Rectangle R1) function? And then, how to return a Point from that function?

My IDE is visual studio 2012.

View 19 Replies View Related

C :: Produce Image Using GD Graphics Library?

Mar 20, 2013

I am trying to produce a image using GD graphics library. I can succesfully display my image, however I cant display this image along with a printf function too?

Code:
#include <stdio.h>
#include <gd.h>
int display_picture()
{
gdImagePtr gdImage = gdImageCreate( 50, 50 );
FILE *jpgFile = NULL;

[Code] ....

The picture displays but not hello.

View 5 Replies View Related

C++ :: Produce Loading Bar With Percent Progress Below?

Aug 10, 2014

#include<conio.h>
#include<windows.h>
#include<stdlib.h>
#include<string.h>
#include<time.h>
#include <stdio.h>

void loading();
void gotoxy(int x, int y);
int color(int x);
void gotoxy(int x, int y);

[Code] ....

How to produce a loading bar with percent progress below.

View 1 Replies View Related

C++ :: How To Produce Password Field With Asterisk

Sep 2, 2014

void Log_In() {
system("cls");
gotoxy(30, 30);
time_t now;
time(&now);

[Code] .....

How to produce a password field with asterisk ****** .....

View 1 Replies View Related

C# :: How To Add A Timer Or Loop To Produce RSSI Value

Oct 24, 2014

I have a code which basically produces the RSSI value in a command prompt window once i run it but i want to add a function to it which would let the RSSI reproduce itself (once every 5 seconds or something) once its run without having to physically compile it every time.

using System;
using System.Collections.Generic;
using System.ComponentModel;

[Code].....

View 14 Replies View Related

C++ :: Add 2 Asterisks For Each Line

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

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 View Related

C/C++ :: Infinite Loop Of Asterisks Or Nothing At All?

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

C/C++ :: Random Number Of Asterisks Between 0 And 90

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

C++ :: Produce Normal Distribution Random Number Several Times

Aug 22, 2014

I wrote the following program shown below that produces a normally distributed random number several times, and then takes the average of them. The problem that I have been having though is that the output it has been producing is 0.0288385 despite the fact that I set the mean of the normal distribution to be 0.1. Why this output value would be so far off from 0.1 despite having averaged over such a large number of random numbers namely 10,000 of them? Also, how to randomly seed this random number generator such that it gives a different value each time its run perhaps by seeding it with the windows timer? Below is the program.

#include <iostream>
#include <random>
using namespace std;
int main() {
default_random_engine generator;
normal_distribution<double> distribution1(0.1,3.0);
double number1,sum,n;

[code].....

View 2 Replies View Related

C++ :: Print Asterisks To Correspond To Program

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

C++ :: Print Equilateral Triangle With Asterisks?

Feb 22, 2013

how can i print an equilateral triangle with asterisks .

View 3 Replies View Related

C# :: How To Display Input Number Of Asterisks

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

C/C++ :: Read From Dat File And Produce Output On Screen - Error C2664

Feb 5, 2014

My professor wants me to write a program that will read from a dat file, and produce an output on the screen based on the file. I don't understand why I am getting this error. I suspect it has something to do with the number of characters I've told it to read.

#include<iostream>
#include<iomanip>
#include<fstream>
#include<assert.h>
#include<string>
using namespace std;
using namespace System;
struct TStudent {
string month[10];

[Code] .....

I noticed I had a 2 beside girl, after I removed it, it still didn't fix my problem.

View 8 Replies View Related

C++ :: Program To Read In Sequence Of Examination Mark From Text File And Produce Mean

Jan 26, 2013

Write a program to read in a sequence of examination mark from a text file named as input.txt and produce the mean, and standard deviation of the marks. Your program should also produce a bar chart for each grade where the range of mark is given as below.

GradeMarks Range
A80-100
B70-79.9
C50-69.9
D40-49.9
F0-39.9

Output the result to another text file named as output.txt.

View 3 Replies View Related

C++ :: Program That Count Occurrence Of Character In Text File And Produce Histogram

Nov 18, 2014

Here is what i have so far:

#include<fstream>
#include<iostream>
#include<string>

[Code].....

I also need to do a loop that scan the count array and check if the element is bigger than the previous one.

View 1 Replies View Related

C++ :: Making Diamond Out Of Asterisks Based On Given Odd Integer Input

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

C/C++ :: How To Print Random Number Asterisks On Two Separate Lines

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

C++ :: Print In Asterisks Oval / Arrow And Diamond Using For Loop And If Statements

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

C/C++ :: Printing Square Pattern Of Asterisks Based On User Input

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

C/C++ :: Create A Program That Prints A Certain Number Of Asterisks Based On User Input

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

Visual C++ :: Retrieving Size Of Each String In Order To Produce A New Buffer For Concatenated String

Feb 25, 2013

What is the efficiency of the two assignments (line 1 and 2), i.e. (function calls, number of copies made, etc), also the Big O notation. I know there are function calls for retrieving the size of each string in order to produce a new buffer for the concatenated string...any difference between line 1 and 2 in terms of efficiency?

String s("Hello");
String t("There");
1. s = s + t;
2. s += t;

View 3 Replies View Related







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