C++ :: Program To Tell Whether Number Is Prime Or Not - Illegal Structure Operation
Mar 2, 2013
In 83rd line message says: "Illegal Structure operation". But I didn't use any structures! How to correct it?
#include<iostream.h>
#include<conio.h>
#include<math.h>
int prime(int);
int reverse(int) ;
int power(int,int);
int rectangle(int,int);
int square(int);
int circle(int);
void tables(int);
[Code] ....
View 6 Replies
ADVERTISEMENT
Mar 19, 2015
#include<iostream.h>
#include<conio.h>
class date {
int dd,yy,day,*incr;
char *mon; //first latter
public:
void setptr(date *m);
[Code] ....
View 1 Replies
View Related
Dec 20, 2013
#include<iostream.h>
#include<conio.h>
#include<string.h>
#include<stdio.h>
class complex {
int real,imag;
[Code] .....
View 2 Replies
View Related
Aug 1, 2013
#include<iostream.h>
#include<conio.h>
class sum {
int a,b,ans;
public:
void geta() {
cin>>a;
[Code] ....
View 1 Replies
View Related
Sep 17, 2013
CODE:
class Secure {
private:
int seconds;
bool isRUNNING;
public:
Secure(int seconds) {
[Code] .....
ERROR:
error C2276: '&' : illegal operation on bound member function expression
I read that due to explicit casting, threads cannot be created within a class. I'm trying to thread a scanning system to relieve stress on my main program/module, rather than having the scanner stunt their performance.
View 4 Replies
View Related
Dec 2, 2014
I have a program that gets prime numbers that doesn't work. It looks like it works for all prime numbers except odd non-prime ones. Here is the code:
Code:
#include <iostream>
using namespace std;
bool isPrime(int prime) {
while(true) {
int track = 0;
[Code] ...
View 3 Replies
View Related
Nov 3, 2013
I need to write a program that will allow the user to enter a number "n" and the program tell you that the nth prime number is .....
EXAMPLE
user enters 55
printf("The 55th prime number is %i", variable");
View 1 Replies
View Related
Jan 12, 2013
What is the minimum range of numbers which we need to go necessarily to check either a number is prime or not?(for all integers) ....
View 6 Replies
View Related
Nov 11, 2013
how to make a programm in native c++ which print out all prime numbers less than or equal to given number????????
View 5 Replies
View Related
May 2, 2014
So I need to write a program which tells the user if the number they input is prime or not. I have done so and included the code below. My problem is that I need to allow the user to input if they want to enter another number after the first one using y or n and I am having trouble figure it out.
#include <cstdlib>
#include <iostream>
using namespace std;
[Code].....
View 5 Replies
View Related
Aug 24, 2014
I'm a new coder for C++, and I've recently learned java before starting this programming language. I'm attempting to find all prime numbers up to the number a user enters (i.e. User enters 10, System shows "1,2,3,5,7"),
#include <iostream>
#include <cstdlib>
using namespace std;
int main(int argc, char** argv) {
int num;
cout << "Enter a positive number." << endl;
[Code] ....
I've been looking at my forloop, and I can't seem to pinpoint the problem with it.
View 1 Replies
View Related
Nov 20, 2014
I am attempting to write code that receives a number from the user and outputs the largest prime number underneath the user's number. There are no errors in my code, but no matter what number is imputed, the program says the largest prime number is 1. I cannot find where the issue is in the code. Here is the code I wrote:
#include <cstdlib>
#include <iostream>
#include <cmath>
using namespace std;
bool isPrime(int num);//function prototype
[Code] ....
View 2 Replies
View Related
Apr 14, 2013
The project is "Design and write a program to model the operation of incoming flights computer screen that is normally found at a typical small airport like Moshoeshoe I airport (if they do have one). The following provides the information that needs to be displayed about each flight:
• Airline - [string of maximum length 15] Name of the airline, eg. FlySAA
• Flight Number - [string of maximum length 5] eg. 04120
• Origin - [string of maximum length 25] Place where the flight originated from eg. Johannesburg
• Date/Time - [integers: Hour, Minute, Day, Month, Year] Arrival time of the flight
• Status - [string of maximum length 15] Whether the flight is "OnTime" or "Delayed"
View 4 Replies
View Related
Nov 7, 2013
#include <iostream>
using namespace std;
int main() {
//input output
[code]....
its supposed to tell whether the inputted number is prime or not
View 1 Replies
View Related
Oct 22, 2013
I have to create a program where I need to find the prime factors of a number and express it using exponents.
For example, for the number 1368 should output:
1368 = 2^3 * 3^2 * 19^1
This is my code:
void primeFact (int n){
int i;
int score = 0;
[Code].....
View 3 Replies
View Related
Dec 9, 2013
I am trying to factorize semi-prime numbers by using a brute force method and a square root method.The brute force method should start by multiplying all odd numbers between 1 and the semi-prime number. Meaning that 1 should multiply 3 then 5 then 7, etc. Then three should multiply 5 then 7 then 9 and so forth. The first number would never multiply a number equal to or less than itself.
bruteForce(int x){
f1 = 1;
f2 = f1 + 2;
while (f1 < x){
for (f2 = x; f2 <= x; f2-2){
[Code] ....
For my other algorithm, I want it to get the square root of the semi-prime and then start multiplying odd numbers around it. I made it so that the square root would have to be set to the next even number (in case it was a factor). If the product of the two odd numbers (a * b) is greater than the original semi-prime, I would multiply b by the next smaller number than a. Conversely, if the product of a and b is less than the original semi-prime, it will multiply a by the next odd number larger than b. This will repeat until the two correct factors of the original semi-prime are found.
Algorithm:
SquareRootFactorize(int x){
int N = x;
sqrtN = sqrt(N);
if (isOdd(sqrtN) == true)
sqrtN = sqrtN + 1;
f1 = sqrtN - 1;
f2 = sqrtN + 1;
[code].....
View 1 Replies
View Related
Mar 14, 2014
I wrote this program to print prime numbers between 2 and 10 but it only prints '3'. here is the code
#include<iostream>
#include<conio.h>
using namespace std;
int prime(int x, int y);
void main(){
int n=2;
[code].....
View 6 Replies
View Related
Mar 14, 2015
We are working on building a cluster and needed to create or find a program writen in C that we can run. I was thinking a program that finds prime numbers and insert them into a MySQL database. I have never worked with C so I don't know where to start or anything. I have a week to prove our project is worth keeping and our cluster is almost completely installed we just need to create a program.
View 4 Replies
View Related
Oct 3, 2013
cin.ignore (10);
return 0;
}
Its not working
View 2 Replies
View Related
Feb 23, 2014
I have to write a program that asks the user to input a positive integer, counts how many primes there are before this integer, then divide the number of primes by the integer. Here's what I have so far:
int n;
int counter = 0;
cout<<"Enter a positive integer n.";
cin>>n;
[Code]....
the value of the integer counter is supposed to increase whenever a prime number is identified but it's increasing n times
View 8 Replies
View Related
Oct 3, 2013
We need it to say if the number is prime or not we need the equation for the if statement or if we have something else wrong to let me know.
#include <iostream>
using namespace std;
int main () {
int number;
bool countr;
for (countr = 0; countr <= 2; countr ++)
[Code] ....
View 1 Replies
View Related
Mar 13, 2014
my assignment is to print out the numbers from 2 to 20 stating if they are primes or not using loops and/or a function..once i execute, it throws the program into an infinite loop...
#include <iostream>
#include <cmath>
using namespace std;
bool prime(int n);
int main()
{
int i;
View 4 Replies
View Related
Oct 19, 2014
Can I possibly get a better implementation of a prime number detecting algorithm than the one I already have below?
Code:
#include <cstdio>
#include <cstdlib>
int main() {
int no, high, low;
int divisor;
[Code] .....
View 8 Replies
View Related
Feb 17, 2013
Basically, I am suppose to compute 10 numbers and find their highest prime number for each of them. I've already have the inputs working, and set up 2 arrays to store inputs and their highest prime number. But I am uncertain on how to find and store their highest prime number. How to start it off?
View 7 Replies
View Related
Oct 10, 2013
how would I write a while() loop that calculates the sum of all prime numbers from 1 - 50.
View 5 Replies
View Related
Oct 20, 2014
#include "stdafx.h"
#include "iostream"
using namespace std;
int main (){
int x;
int i;
int e;
[Code] ....
is the logic good ? and why the program is looping
View 3 Replies
View Related