C++ :: Write Program To Find Area Of A Square
Feb 1, 2013write a C++ program to find the area of a square, input the length of the side, and output your answer to the screen.
View 3 Replieswrite a C++ program to find the area of a square, input the length of the side, and output your answer to the screen.
View 3 RepliesArea of the room. Your task is to write a program that will find the area of room in a given square maze.
Note. Use recursion for solving this problem.
Input:
First line contains only one number N (3 <= N <= 10).The number that describes the size of the square maze.
On the next N lines maze itself is inputed ('.' - empty cell,'*' - wall).
And the last line contains two numbers - the row and column of the cell in the room those area you need to find.It is guaranteed that given cell is empty and that the maze is surrounded by walls on all sides.
Output:
Output only one number - total amount of empty cells in the selected room.
B. Circle in a Square Write a C++ program that will ask the user to enter the area of a square. Then the program will display the biggest area of a circle that will fit in a given square. Using math.h library is not allowed.
View 1 Replies View Relatedi have written a program to find area of triangle, but i meet some errors,
//******area of triangle******//
#include<iostream>
using namespace std;
[Code].....
I want to find transpos of square matrix.but my program does not run complete.
Code:
#include<iostream>
using namespace std;
const int size=3;
void read(int a[size][size])
[Code] .....
I am writing a program to find the square root of a number. I am using the Newton-Raphson method..Just to clarify a bit of the code.. fabs(1/(x+1)) < 0.001 is to check for relative error..
EXAMPLE: for user entry of 100 if the iteration process ends in 10.055 the answer will return as 10 which is correct. But it isn't doing that.
It compiles I then proceed to run it..prompts me "Enter a number to find the square root of: I type 100 then hit enter...
"The square root of 100 is -1077834936"
My first time writing a program from complete scratch.
And I know there is a sqrt() function...just wanted to write my own.
Code:
#include <stdio.h>
#include <math.h>
double mysqrt(double a);
int main()
{
double a, result;
printf("Enter a number to find the square root of: ");
[Code]...
Given that today is June 9, thursday, write a program that will print the day of the week on June 9, after x years from now. Assume one year is 365 days.
View 2 Replies View Relateduser enter four number and the output will be the greatestt number among these
View 1 Replies View RelatedHow to find triangle in an array of n triangles which has the largest area?
#include <stdio.h>
#include <stdlib.h>
#include<math.h>
typedef struct {
double x,y;
[Code] .....
I having trouble with the rational class
here is my assignment:
Add a square root function to the rational class. Have your program print the square root of any rational number. I want to find the square root for numerator and denominator separatetly. divide the answer to get decimals and convert the decimal to fractions. i got till geting the decimal but i want to convert it back to a simplified fraction
// finding greatest common factor
int gcd(int a, int b)
{
if (b == 0)
return a;
else
return gcd(b, a % b);
}
[Code]...
How can i come up with a program that uses entered radius of a circle to find its area
View 1 Replies View RelatedI 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.
I trying to write a program that calculates the area and circumference of a circle.
This is what I wrote so far.
Code:
#include <stdio.h>
void main()
{
int r;
int pi=3.14159265;
float cir,area;
printf("
enter the radius of the circle ");
[Code]...
the Problem is when I input the radius the answer I get is zero regardless of the the radius. Am I missing something?
#include <iostream>
#include <conio.h>
#include <iostream>
[Code].....
I can't find a way to square and cube the number I want, which the number will show in the notepad. Is there a way to cube and square a number in my program??
I want to make program to square the numbers from 1 to 20. i have written this program, it's running but not giving the required answer.i think it is giving a garbage value...
void main(void)
{int a;
int b;
b=a*a;
for (a=1; a<21; a++)
{printf("%d",b);
printf("the square is%d=b");
}
getche();}
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] .....
I have been trying to write a Newton's Method program for the square root of a number and have been failing miserably...
#include <iostream>
#include <cmath>
using namespace std;
int main() {
double x1;
double y;
double x0;
[Code] .....
I'm working on a c program that generates approximations of square roots based on newton raphson method. I worked out the approximations with another method I learnt and I know this program does fine. But I don't get the concept of epsilon. Below is the code for the program
Code:
#include<stdio.h>
// function to compute absolute value
float absoluteValue(float x)
{
if(x < 0)
x = -x;
[code]....
The text I worked this code from uses the epsilon value arbitrarily. how is the epsilon value selected? I tried using this formula to derive the square root of 45. On paper I can go as far as 6.8 something. But once this value is reached it's still bigger than epsilon, so shouldn't the code keep running? The program generates 1.41 for 2, but since it could go further why does the while loop in squareRoot function terminate?
I have to prepare a project. But I don t know how can I do this. Program will find a matrix P for a square matrix A such that P^-1 A P ....
View 15 Replies View RelatedI got an assignment at school asking for a program that can implement functions that store, get and deletes text/binary data to a given memory area. We are supposed to make kind of like a tiny-mini OS..any links to some tutorials or explanations hon ow to understand this and be able to make a program like this on my own?
View 9 Replies View RelatedCreate a user-defined program that will compute the price per square inch of a cake using an “overloading”. The cake could be a circle or a square type. In the main function, ask for the price of a circle cake and its diameter, while for the square cake, ask for the price, its length and width. The process must be done inside the different function of each cake. (Note: two sub function for the computation of a circle and a rectangle)
Note that when I made this program something weird happen. After inserting the name, all things follow.
<code>
#include "stdafx.h"
#include <iostream>
using namespace std;
double areaRectangle(int l, int w);
double radiusCircle(int r);
[Cpde] .....
I am trying to write code to find all the prime numbers before a user entered number. I started with a working program and when I tried to create a function, it got all messed up.
Code:
#include <stdio.h>
int is_prime( int num );
int get_positive_integer(void);
int main( ) {
int upper; /* upper limit to check */
int num; /* current number to check */
int isprime;
/* used to flag if number is prime or not */
[Code]...
It says the error is on line 23
I'm new in programming, and trying to write a code in C. The requirement is following - to write a text, and to find frequency of 1 chosen character in it. The main thing is that program should check user input (for example, I want to check if user entered "char" --> then correct, or if entered "int" --> not correct). But the program still doesn't check. So I have:
Code:
#include <stdio.h>
int main(){
char c[1000], ch;
char i, count=0;
printf("Enter a text: ");
gets(c);
[Code] ....
Am I on my right way using if/else?
im trying to write a source code that find the smallest, largest and average of numbers in array. the code runs fine, but it is not giving the highest number and the the average should include only four number excluding highest and smallest number from the array.
void OlympicJudging() // Olympic Judging {
int numbers [6];
double average, sum = 0;
int temp;
for(int i = 0; i < 6; i++){
cout << "Please type a value for scores: ";
cin >> numbers[i];
[Code]...
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] ......
For instance Code: int counter;
counter =0;
FILE *pfile;
pfile= fopen("g:myprog.txt" "w");
while (counter >100)
{ fprintf (case counter{something})}; how do I do this?