I got the upper pattern but below pattern is not working it executes infinte loop, how to reslove this.
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ro { class ro { static void Main(string[] args) { int numberoflayer = 5, Space, Number;
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 am trying to compare a double to be within various ranges, but the comparison is not working correctly. Rounding precision is not a concern, because if the value will match the boundaries so rarely, and it is rounding up to the higher range is acceptable. Below is the doe at issue:
if (kq == 2) { if (fundt[kq-1][ky-1][2-1] < 450,000,000.00) ktti[ky-1][0] = 1; else if ((fundt[kq-1][ky-1][2-1] >= 450,000,000.00) && (fundt[kq-1][ky-1][2-1] < 525,000,000.00)) ktti[ky-1][0] = 2; else if ((fundt[kq-1][ky-1][2-1] >= 525,000,000.00) && (fundt[kq-1][ky-1][2-1] < 650,000,000.00)) ktti[ky-1][0] = 3; else if ((fundt[kq-1][ky-1][2-1] >= 650,000,000.00) && (fundt[kq-1][ky-1][2-1] < 750,000,000.00)) ktti[ky-1][0] = 4; else if ((fundt[kq-1][ky-1][2-1] >= 750,000,000.00) && (fundt[kq-1][ky-1][2-1] < 850,000,000.00)) ktti[ky-1][0] = 5;
[Code] ....
I know that a triple-dimension array looks complex, but I can guarantee that is a double. The literal constants I am using should automatically be doubles. The subscript of [2-1] looks odd, but this is code I was given to maintain, and that is how it is written elsewhere, so I kept it for consistency. The problem I am having is that when I run this code, all the data I input is less than the 450 million value, but the run falls through all the if and if-else conditions, and the else code is what is actually executed, i.e., I always get six as my result.
I am running on a Sun Sparc, and the compiler used is SunStudio 12. I have tried using variables, with the values listed above assigned to each variable, but it does work either. When I use variables, if the input value is negative, the comparison for less than 450 million works, but any positive input values will through to the else and give me six.
I'm currently working on a simulation of the motion of magnets on a rod. As part of it, there are arrays of the properties of the magnets:
long double *accelerations; // These will later be dynamically allocated depending on the number long double *velocities; // of magnets long double *positions;
However, when I go to compile this, the compiler gives me these error for the pointers:
error: two or more data types in declaration of 'accelerations' error: two or more data types in declaration of 'velocities' error: two or more data types in declaration of 'positions'
Apparently, the compiler isn't recognising long double* as a type and is instead reading is as the two types long and double*.
How to draw a hollow triangle given a user input indicating the number of rows.
Eg: Number of rows = 4 ___* __*_* _*___* *******
My idea was to split up the triangle into three parts (first row, middle part, last row) and I've managed to write some code on printing the first and last row of the triangle
Code: int main() { //Declaring the variables. int rows, position; //Prompts user to enter number of rows. printf("Enter the number of rows in the triangle: "); scanf("%d", &rows);
[Code] .....
What to do so that I can print the middle part of the triangle. All I know is that I need to use loops. I've also been told that drawing a flow chart would work but I really don't know how to even begin with a flow chart then transform it into code.
C programming: I want to creat a program that asks the user to input the integer lengths of three sides of a triangle, and if so whether the triangle is a right-angled, acute or obtuse one. i am having some doubts about the if, else if statements. I never seem to know how and in what order to use them.
Code:
#include <stdio.h> #include <stdlib.h> #include <math.h> int main(int argc, char *argv[]){ int SideA; int SideB; int SideC; }
Basically I'm having trouble reading more than one character.I want the user to input character traits(ie, w, a), if two traits are entered they get the job.
But I cannot get my program to read more than one character input.
This is what I have so far...
#include <iostream> using namespace std; int main(){ char input; int count = 0;
I'm having trouble printing the text in between separators like commas, periods, and at signs. I'm following Jumping into C++ Chapter 19 Practice Problem 2.
This is what I have so far:
Code: #include <iostream>#include <string> usingnamespacestd; int findNeedle (char separator, string inputLine) { int needleAppearences = 0;
[Code] ....
And this was my test run output:
Enter the contact info. one, two, three, ,? , one two, th three, Program ended with exit code: 0
Whenever I try to call merge sort on large numbers say n=10000000. It gives an error. It works fine for small numbers, even though I have declared my Lists on the heap.
I would like to print a multiplication table, with the dimension n given as input. I attached how the table looks like for n=7.
How do you output the character "-" in that sequence? The first and last numbers have 13 "-" characters before and after them, but the numbers in between have 8 "-" characters.
//Finding prime numbers #include <iostream> using namespace std;
[Code]....
/*The program currently prints all the prime numbers up to n (For example, if 7 is entered, it prints out: 1, 2, 3, 5, 7. What I want it to do, is print out the first 7 numbers; 1, 2, 3, 5, 7, 11, 13.
Why my output screen for this program does not want to stay open. It only opens for a split of a second and it's gone. The program is supposed to take numbers from a input file and display and save the manipulation in the output file. Here is the program.
I'm having troubles with this program I made. Put it simply, it's a basic program using Queues. Whenever I try to input a value, my compiler(Dev C) suddenly stops working. The .exe file crashes and I've no way on how I can execute my program.
Code : #include<iostream> using namespace std; int *queue; int rear, front, queueSize; void enqueue(); void dequeue(); void display();
I'm trying to write a C++ program that will allow a user to input a number from the keyboard. Then using a loop, that will perform 10 times, multiply the entered number by the loop counter. Print out the loop counter, the entered number and the product of the loop counter and the entered number. A one-time heading should be displayed before information is printed.
This kinda of what I have so far:
#include <iosteam> using namespace std; int main () { Start Declare: numScores, sum, score, avg, SENTINEL = 200 numScores = 0
[Code] ....
All the programs I have tried to make are not working?
I wrote this program to create a list of medical resources and their attributes, a task I have been performing repeatedly lately. I'm still fairly new to C++, so I thought to create a structure "Resource", and then an array of those structures "city[300]". My problem is that the input doesn't seem to be happening: the program runs, but when it prints to screen/writes to the file at the end, all the shows is:
Resource Type: Name: Address: Phone: Website:
for every resource that was input. All the fields are blank.
Following is the program I wrote it basically takes 9 inputs and then save them into binary file. then print out the data stored in binary data and find inverse of it then print the inverse out. but its stuck in a loop somewhere.
Code: #include <stdio.h> int main() { int a[3][3],i,j; float determinant=0; int x; FILE *fp = fopen ("file.bin", "wb");
Now it has to be modified in order to accept the input 2,2 4,4 and 6,8(only an example) and be able to find out if it is a right triangle. I was told that arrays were not necessarily the only way to go about it.
I need to find out neighbors of a triangle and loop it over entire unstructured grid. How to do it?. Cell numbers are random so I am unable to loop over all cells.
I intended to compute perimeter of a triangle. The problem is the initial value for the triangle.
#include <iostream> #include <cmath> using namespace std;
struct Point{ double x; double y;
[Code] ......
I expect to get 0 for triangle1, but I get some strange value...
Here is the result
Type x for point1 : 1 Type y for point1 : 1 Type x for point2 : 3 Type y for point2 : 1 Type x for point3 : 1 Type y for point3 : 3 The perimeter of the triangle1 is : 2.82843 The perimeter of the triangle2 is : 6.82843