This problem is to print a square using a number that the user enters, which would be in the center. If the user entered a 5, then the program should output this: 111111111 122222221 123333321 123444321 123454321 123444321 123333321 122222221 111111111 If you're wondering, this was not a homework assignment. It was on a quiz, and I did not know how to do it. So if someone could give me at the very least some guidance on how to solve this problem, then that'd be nice. I know that I need to use for loops, but I'm not quite sure … |
+0 forum
17 | ||

I'm so confused on this, can anyone please give me a hand. Thank you in advance. A program that uses the numbers from 1 - 12 and output the number, the square of the number, the cube of the number and finally the square root of the number. At the end give me a grand total of the square roots. |
+0 forum
5 | ||

Hi everyone, i need your help.. I want to draw a circle,square and rectangle on Jframe on a click of a button.. This program was asked in my test paper, i couldn't get it right though bt i wanna know what my mistake is.. Plz help me.. import javax.swing.*; import java.awt.*; import java.awt.event.*; public class CRS extends JFrame implements ActionListener { JButton b1,b2,b3; Graphics g; Container con; public CRS() { super("Draw Circle in JFrame"); con=getContentPane(); con.setLayout(new FlowLayout()); b1=new JButton("Circle"); b2=new JButton("Rectangle"); b3=new JButton("Square"); con.add(b1); con.add(b2); con.add(b3); b1.addActionListener(this); b2.addActionListener(this); b3.addActionListener(this); } public void Circle() { g.drawOval(50,50,100,100); } public void Rectangle() { … |
+0 forum
1 | ||

a hollow square. 5x5 |
+0 forum
3 | ||

So i have to write a c++ program for the Graeffe's square root method I have am stuck here when i have this formula transform into c++ code, the formula is on the link The code works particulary, the (elem[j-1]*elem[j+i]) doesn't work, it's beeing ignored and i don't know why... can any one help me? [http://latex.codecogs.com/gif.latex?A_{k}=a_{k}^{2}+2\sum_{s=1}^{k}(-1)^{s}a_{k-s}*a_{k+s},&space;k=0,....n](http://latex.codecogs.com/gif.latex?A_{k}=a_{k}^{2}+2\sum_{s=1}^{k}(-1)^{s}a_{k-s}*a_{k+s},&space;k=0,....n) cout<<"How many elements?"<<endl; cin>>n; cout<<"Insert the elements:"<<endl; for(int i=0; i<n; i++) { cin>>elem[i]; } C[0]=pow(elem[0],2); for(int j=1; j<n; j++) { C[j]=pow(elem[j],2); int i=1; while((i+j)<=n-1&&(i<=j)) { C[j]=C[j]+(-1)^i*2*(elem[j-1]*elem[j+i]); i=i+1; } cout<<"C"<<j<<":"<<C[j]<<endl; } |
+0 forum
2 | ||

For my c++ class i have to write a code that will read integers in to a 2D array from a file and then, using functions/methods, determine if the array is a magic square. My problem is that when i build or compile i get "error C2664: 'DataIn' : cannot convert parameter 1 from 'std::ifstream' to 'std::fstream &'" Here is the code: #include <iostream> #include <fstream> using namespace std; void PrintMatrix( int x[][20], int size) { for(int i = 0; i < size; ++i) { for(int j = 0; j < size; ++j) { cout << x[i][j] << "\t"; } … |
+0 forum
4 | ||

hiii.! how to make a hollow square of asterisks by entering a size of side by user, for example if 4 is entered then, it will be print, * * * * * * * * * * * * of 4*4. |
+0 forum
2 | ||

how to test if a num is a square root? ex: 9 is square root 3 is not square root ///////////////////////////////////////////// //do not worry about sytax. int x = 0; //always start at 0 int y = 101010; //is this a square root? square(x, y){ if((x*x) >= y){ //not a square root return false; } else if((x*x) == y) //it is a square root return true; } else{ //inc x by 1 square(x+1, y); } } this algorithm works fine when y is small int. ex 4, 10, 20. but when i put y to be large ex 10000. than … |
+0 forum
3 | ||

I’m making programs which will separate a two digit number from a textbox to two different labels. Later I want to take those two separate numbers and square them indiviudally and add them together. It would be great if someone can get me some help. This is what I have so far: Public Class Form1 Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click Label1.Text = "First digit:" & TextBox1.Text.Substring(0, 1) Label2.Text = "Second digit:" & TextBox1.Text.Substring(1, 1) Label3.Text = (Label1.Text) ^ 2 End Sub End Class |
+0 forum
2 | ||

I was wondering the best way to implement a square root button. Below has everything from 0-9, the four functions, and a decimal and clear function. Dim valueOne As Single Dim valueTwo As Single Dim operation As Integer Dim answer As Single Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Me.TextBoxDisplay.Text += "1" End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click Me.TextBoxDisplay.Text += "2" End Sub Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click Me.TextBoxDisplay.Text += "3" End Sub Private Sub Button4_Click(ByVal sender As System.Object, ByVal … |
+0 forum
5 | ||

public static void sumOfSquareRoots() { Scanner scan = new Scanner( System.in ); double value; // read in a double System.out.print ("Enter a double:"); value = scan.nextDouble(); // calculate its square root double result = Math.sqrt( value ); // write out the result System.out.println("square root of your number is " + result ); System.out.println("The sum of square root of numbers is"+result); } "This calculates the square root of a given number how do I add multiple numbers and add the sum of the square roots ? |
+0 forum
2 | ||

I have a code on the Internet and I have rewritten it, but there are t and n3 variable in the odd_order function that I don't understand their meaning. Please help me to explore it. :D. This code is generating a odd order magic square. <html> <head> <title>Magic Squares</title> <script language=JavaScript> <!-- hide var matrix; // compute ... function compute() { var i; var N = parseInt(calc.square.value, 10); if (isNaN(N)||(N < 1)) { window.alert("Invalid input!"); return; } // end if matrix = new Array(N); for (i = 0; i < N; i++) { matrix[i] = new Array(N); for (j = … |
+0 forum
2 | ||

Dear All, I have written a program to find the smallest divisor of an input number. The code gives me an error in lines 19 and 23. The error is invalid operands to binary %. Please help me to troubleshoot, thank you. Below is my code: #include<stdio.h> #include<stdlib.h> #include<math.h> int main() { int n,r,sdivisor; double d,sqroot,comp; printf("Enter the number whose smallest divisor has to be found"); scanf("%d",&n); if(n%2==0) { printf("the smallest divisor is 2"); } else { sqroot=sqrt(n); d=3; } comp=n%d; while(comp!=0 & d<sqroot) { d=d+2; comp=n%d; } if(comp==0) { sdivisor=d; } else { sdivisor=1; } system("pause"); return 0; } … |
+0 forum
0 | ||

Dear All, I have written a program that finds the integer whose square is closest to but greater than the integer number input as data. But it is giving me an erroneous answer. My algorithm is: 1. Select a number which is half the input number. 2. Square it and check whether it satisfies our condition. 3. Subtract one and square it and check whether it satisfies our condition. 4. Repeat 2 and 3 iteratively until a solution is obtained. Below is my code for the above problem. #include<stdio.h> #include<stdlib.h> #include<math.h> int main() { int n,m,input,powm,pown; printf("Enter a number"); scanf("%d",&input); … |
+1 forum
1 | ||

I was doing some past exam questions as a way of studying for an exam next month. One of the questions that I could not do was this: "Write a procedure that returns a two dimensional square array of size n x n, initialised with random real numbers between -100 & 200". I have two problems with this question. Firstly, how can I manipulate my loop to include negative values (i.e. 'real' as opposed to 'int')? Secondly, how can I make it any square array, like a 2 x 2 or 17 x 17, for example? Any help would be … |
+0 forum
4 | ||

Program created in BlueJ: For this Assignment I am to create a magic square from odd numbers >= 3 input by the user. I want to test my code to see if it works, but I can't figure out how to actually print the square from the number input by a user. When the program compiles, and I run it the terminal window doesn't even show up, before I started messing around trying to figure out the printSquare method, it would show and ask for user input. My program has to be in 2 classes. MagicSquare and MagicSquareTester. [iCODE] public … |
+0 forum
0 | ||

How print this series in while loop square root 1 2 4 8 16 32 64 128.......... and cube root 2 8 24 72........ |
+1 forum
3 | ||

Hi :) I am trying to make a program that will find the first x perfect squares. I have done and redone this many times, but it never works. So basically, it needs to do two things: check if y is a perfect square. If it is, it needs to check if this number is a magic square. A magic square is a perfect square where you can do 1+2+3+4 and so on, and end up with a perfect square. This for my AP comp sci class, and the full assignment is here: [url]http://www.howard.k12.md.us/rhhs/helloworld/LessonA12/Lab-A12-1.html[/url] [CODE=java]import java.util.Scanner; public class FunLoops {import … |
+0 forum
16 | ||

Im writing a code that ask for two positive integers entered from the keyboard. The first integer N is odd in range of 3-15 and the second with be an initial value I. N will be the size of the array. Beginning the center of the NxN array with the integer I. If I is prime then print the number I in that position of the square. Otherwise print three asterisks in that position. Move to the right one square , and test the integer I+1 for primality. Print I+1 if it is prime and three asterisks if it is … |
+0 forum
1 | ||

Good Day Everyone here is my code so far [CODE] #include <graphics.h> #include <stdlib.h> #include <stdio.h> #include <conio.h> void vp(int x,int tc,int bk,char *text); void square(int x,int y,int size); void main() {//=========================================================== int gdriver = DETECT, gmode, errorcode; initgraph(&gdriver, &gmode, "C:\\TC\\BGI"); //------------------monitor-------------------- setbkcolor(0); setcolor(15); square(300,160,150); square(300,160,148); square(300,160,130); square(300,160,131); setaspectratio(2,5); int stangle=0,endangle=180;int radius = 100; setcolor (2); // This becomes drawing color square(300, 160, 128); // Draw the circle setfillstyle(1, 2); // Set pattern to fill interior floodfill(300,160, 2); // Fill the circle setcolor(15); /* draw arc */ arc(295+9, 353, stangle, endangle, radius); arc(295+9, 354, stangle, endangle, radius-1); arc(295+9, 355, stangle, … |
+0 forum
1 | ||

Reusable Code Snippet
Square root extractor Hi.Someone asked a day or two ago for a way to extract the square root of a number without using the std::sqrt function so i thought about writing my own.Here it is and please feel free to criticize. |
+0 forum
1 | ||

In this program i am trying to find numbers that are multiples of 7,11, or 13, also if the total of the numbers is even or odd also the square root value of each number also if there are any prime numbers in the list [CODE]#include<iostream> #include<iomanip> #include<fstream> #include<cmath> #include<conio.h> // Associating program identifiers with external file names #define in_file "data.txt"//input file name #define out_file "result.txt"//output file name using namespace std; void multiple(int); void even_odd(int); void square_root(double); void prime(int); int temp_a; double temp_c; int total; int num; ifstream ins;// associates ins as an input stream ofstream outs;// associates outs as … |
+0 forum
5 | ||

hi, i try to make a square number but its not limited by 2. number and the square can be any numbers. so its like n^n. please help me.. i confused how to do this.. any help will be appreciated. thanks. |
+0 forum
3 | ||

Hi all, 1. When I insert an icon in my VB.NET form, for example: a small shield icon, a white box appears around it and it's very annoying and ugly! I want to disappear the white box at the back of my .ico image. 2. This white backgroud not only appears on .ico files, but also on normal image files like .png, .jpg, .bmp. Please help me for both the file types. Any type of help will be much appreciated. Thanks! |
+0 forum
4 | ||

Hello people, Need help with this code here. This code suppose to print blocks of char assigned by user with certain rows and column also assigned by user. For some reason it is giving me error and i don't understand what the problem is Help will be greatly appreciated. Thanks! [CODE]#include <iostream> using namespace std; void func1(int rows,int column,int blocks,char symbol); void func2(int rows,int column,int blocks,char symbol); void display (); int main () { display(); } void func1(int &rows,int &column,int &blocks,char &symbol) { cout << "Please enter Char: "; cin >> symbol; cout<< "Please enter the number of Blocks(Please enter … |
+0 forum
6 | ||

Hello people, This is first time i am using this site to get help. Any way to the point, The code provided below suppose to make a blocks of squares with certain rows and column. All the field, rows and columns are controlled by user. User can also choose which char they want to print( You can use * for simple use). Let me know if any more help needed to solve. For some reason I get error saying that i didn't declare my rows, column and char Help will be greatly appreciated! [CODE]#include <iostream> using namespace std; void func1(int … |
+0 forum
3 | ||

Ok... So I have the following program: [CODE]public int seq2 (int n) { if (n <= 0) return 1; else return seq2 (n - 1) + 2 * n - 1; }[/CODE] It gives the following output: 1 2 5 10 17 26 37 50 65 82 So that means seq2(0) = 1 and I see how that happened. But I don't get the rest :/ For seq2(1), it would just go to the else statement and execute: return seq2 (1-1) + 2 * 1 - 1 which is 0 + 2*1 -1 which is 2-1 = 1. So it's … |
+0 forum
4 | ||

The task is to use a recursive algorithm to determine the sum of two numbers n1 and n2. I just keep on returning to using the formula n1*n1 +n2*n2 The part which I have questions is I don't get how to do this in a recursive way. Thanks! |
+0 forum
9 | ||

For homework, we have to find the time complexity class of certain algorithms and explain why it has that certain complexity class. So, I have a couple of questions: - Why is the first running time always so much longer than the ones after? (setting up the application or something??) - What is the complexity class of an algorithm that draws a square of side length n, like this one: c.drawRect(0,0,n,n); why is it that way? - What is the complexity class of an algorithm that draws a circle of diameter n, like this: c.drawOval(0, 0, n, n); why is … |
+0 forum
3 | ||

Hi everybody! Sorry for my bad english! I have a matrix of integers with a maximum length 6 digits. I must to write program, that checks whether a number is found in the section above the main secondary diagonal of this matrix. I'm beginner in C + + and I know, how to write a two-dimensional array, who will be our matrix. So, our matrix must be a square matrix that means the numbers of the rows and columns must be equals. I found one code, like this task: [url]http://www.dreamincode.net/code/snippet594.htm[/url] This source code is to input a square matrix and … |
+0 forum
1 |

The End.