C++ :: Program Won't Function With Any Number Larger Than 100?

Nov 25, 2014

#include <stdio.h>
#include <iostream>
#include <cstdlib>

[Code]....

View 1 Replies


ADVERTISEMENT

C++ :: Find Next Palindrome Number Larger Than Input Number

Nov 14, 2014

Q. WAP to find the next palindrome number larger than the input number.

for eg:-

Input=25
Output=33

The program is giving correct output for number with all digits '9';

why is it not giving output.

#include<iostream>
#include<string>
using namespace std;
int main() {
int len,flag=1,count=0,num,ind;

[code]....

View 8 Replies View Related

C :: Program Hangs When Larger Input Data

Apr 3, 2013

here is the link to question: [URL] ....

below is my code:

friendship relations #48.cppfriendship relations #48.cpp

I have some question in regards to the b part 2. My code is working fine when the number of input is low. However when I input more larger input data to my program it start to hangs.

Here is the input: [URL] ....

Output: [URL] ....

View 1 Replies View Related

C++ :: Recursive Function - Program Is Returning A Negative Number At The End

Nov 14, 2013

Why my program is returning a negative number at the end...attached is the program:

/*Write a recursive function recursiveMinimum that takes an integer array and the array size as arguments and returns the smallest element of the array. The function should stop processing and return when it receives an array of 1 element.*/

#include <stdio.h>
#include <time.h>
#include <iostream>
using namespace std;
float recursiveMinimum (int ARRAY[], int n);

[Code] .....

View 2 Replies View Related

C++ :: How To Get Larger 2 Out Of 3 Integers

Mar 12, 2014

How to write a simple function that will take 3 ints and find the sum of the higher 2? This is what i got so far:

int findsum(int a,int b,int c)// will find the highest int and return it to our main program {
int max,max2;// this sets our local variable max
// next we will find the larger of our first 2 variables
if( a>=b)
{ max=a;

[Code] ....

How to get the second highest number and add it to max

View 19 Replies View Related

C :: Segmentation Fault For Larger Values

Apr 11, 2013

On compilation the following program does not give any error and when i run this program then sometimes it gives the segmentation fault. Specially with the larger values. I made sure that the values i inputted are not crossing any range of data types i used. I cannot get what is making my code to give segmentation fault error.

Code:
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>

int main()

[Code] ....

View 4 Replies View Related

C++ :: Converting Console App To Larger GUI Based App

Oct 12, 2012

We never got into any gui stuff. It was strictly console apps. That being said I have been able to create a few small apps. I would like to start to create GUI based apps but I am kind of overwhelmed at the choices. I dont know where to go from here. Since I have c++ experience I would think Visual C++ would be the choice but i have been reading a lot of forums and getting other info.

Is there another language I should look at the would allow me to convert my program quicker or easier?

The console program I already created is very very simple and want to make a gui for.

Quick break down.

Reads file
Changes file contents based on search string,
saves and closes file
and kills a windows service
exits

Only thing I want to add would be the ability to run the file from a remote site within the company LAN(not a priority though). Currently it needs to be run locally on the server.

View 5 Replies View Related

C :: Fscanf - Segmentation Fault For Larger Project

Apr 19, 2013

I added this snippet of code to a larger project I use to read some numbers in from a file, but for some reason I'm getting a segmentation fault.

Code:
printf("starting main
");
FILE *cutoffs;
double cut1=0, cut2=0, cut3=0;
printf("trying to open file

The cutoffs.in file looks something like

Code: 3.475 3.875 4.025

I ran the gdb debugger, so I know it is occurring at that fscanf; however, it doesn't give any other details (to be honest I don't have much experience with debuggers :x) ..The values are being put into an array. Before I just had numbers initialized in the array by hand, but need to have 20 different runs of this code with different numbers each time...

View 2 Replies View Related

C++ :: Sort Huge Files (larger Than Available Memory)

May 30, 2012

I am trying to understand what techiques can be used to sort really huge files (larger than available memory). I did some googling and came across one technique.

1. Are there any better ways to get this done?

2. Is there some tweaking that can be done to make this itself better?

Large enough so that you get a lot of records, but small enough such that it will comfortably fit into memory

3. How do you decide on this value? Consider, memory is 4 GB and currently about 2GB is consumed, and file to sort is 10GB in size. (Consumed memory could of course change dynamically during execution - consumed more/less by other apps.)

View 5 Replies View Related

C++ :: Size Of Process Grows Larger For Lots Of Small Memory Allocations

Jun 21, 2013

Why the size of a process grows larger in size for lots of small memory allocations. For example, say I have this struct, which is 16 bytes (for a 32 bit build):

Code:
struct Person {
int iID;
int iAge;
char * pForeName;
char * pSurName;
};

If I allocate memory like this:

Code:
LPBYTE lpB = new BYTE[sizeof(Person) * 1000000];

Then my process grows to 16,48KB in size, which is what I expected. However if I allocate memory like this:

Code:
Person * lpPerson;
for(int i = 0; i < 1000000; ++i)
lpPerson = new Person;

Then the process grows to 78,656KB, which I don't understand.

Additionally, I was surprised to find a vector acts more similarly to the first example. This code:

Code:
Person temp = { 0 };
std::vector<Person> people;
for(int i = 0; i < 1000000; ++i)
people.push_back(temp);

Only increases the process memory to 16,892.

View 5 Replies View Related

C :: Function To Round A Number To Give Integer Number That Is Closer To Real Value

Oct 9, 2013

I was told to use a round function to round a number to give an integer number that is closer to the real value. (for example if the number is 114.67 I need to print an int value of 115 instead of 114)

I am not exactly sure how a round function works, but I am told to include math.h library. What I try doesn't seem to work.

View 1 Replies View Related

C :: Program That Allow User To Enter A Number N And Print Nth Prime Number

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

C/C++ :: Program To Find Number Of Digits In Number?

Aug 20, 2014

In the c pgm to find number of digits , if I am giving 001 as the input number ,why I am not getting the no. of digits as 3?

View 2 Replies View Related

C++ :: Concatenate Two 2-dimensional Int Arrays Into One Larger 3-dimensional Array

Jul 31, 2013

How can I concatenate two 2-dimensional int arrays into one larger 3-dimensional array. This question is also valid for the 3-dimensional vectors. I know the command for the one dimensional vector as:

std::vector<int> results;
results.reserve(arr1.size() + arr2.size());
results.insert(results.end(), arr1.begin(), arr1.end());
results.insert(results.end(), arr2.begin(), arr2.end());

and for the one dimensional array as:

int * result = new int[size1 + size2];
copy(arr1, arr1 + size1, result);
copy(arr2, arr2 + size2, result + size1);

But I do not know how to make a 3-dimensional array or vector.

View 3 Replies View Related

C :: Why Size Of Struct Is Larger Than Sum Of All Size Of Its Members

Jul 11, 2013

I was wondering why, in C, the sizeof of a struct is larger than the the sum of all the sizeofs of it's members. It only seems to be by a few bytes, but as a bit of a perfectionist I fine this a bit annoying.

View 1 Replies View Related

C++ :: Program To Display Even Number From 100 - 200

Jan 23, 2014

i wrote this program to display even number from 100-200. But visual c gives me this error with undeling the "a" in if statement. Error1error C2106: '=' : left operand must be l-value

#include<iostream>
#include<conio.h>
using namespace std;
void main(){
for(int a=100;a<200;a++){
if(a%2=0)
cout<<a<<endl;
}
_getch();
}

View 1 Replies View Related

C++ :: CPP Program To Check Whether A Number Is Palindrome Or Not?

Feb 12, 2014

I could not find the mistake in this program....

Code:
//cpp program to check whether a number is palindrome or not
#include<iostream.h>
#include<conio.h>
//the class
class palindrome

[Code] ....

View 4 Replies View Related

C++ :: How To Square And Cube Number In Program

Feb 18, 2014

#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??

View 5 Replies View Related

C++ :: Make The Program Generate A Different Number?

Apr 23, 2013

i wanna no if i can make the program generate a different number everytime you guess the number right and want to play again. it always generates the same number

#include <iostream>
#include <ctime>
#include <cstdlib>

[Code].....

View 9 Replies View Related

C++ :: Program That Loops X Number Of Times

Feb 20, 2015

I'm trying to create a program that loops "x" number of times, where "x" is going to be a user-input number.

View 2 Replies View Related

C/C++ :: Factorial Program - Input Number

Mar 26, 2014

I'm trying to run a factorial program but I'm getting the error statement has not effect.

here's the code

#include <iostream>
using namespace std;
int main() {
int fac = 0;
int sum = 0;

[Code] ....

the error happened in the int main section

View 3 Replies View Related

C/C++ :: Program Closes When Using Any Number In Switch

Feb 17, 2015

#include <stdio.h>
#include <string.h>
#include <stdlib.h>

[Code]....

when running the program it closses after the switch.

View 2 Replies View Related

C/C++ :: Making A Program That Gives All Primes Below A Given Number

Oct 8, 2014

I'm trying to understand why this won't work, the output i get is a list of even numbers. I'm trying to get all prime numbers below the number thats scanned in.

#include <stdio.h>
int isPrime(int number);
int main(){

[Code]....

View 5 Replies View Related

C/C++ :: Number To Binary Converter Program?

Sep 21, 2014

I recently wrote a program to convert numbers to binary in c++, Well here it is:

#include <iostream>
void recur(int convert) {
if(convert == 0) //if input is 0 , return nothing. {
return;
}
recur(convert/2); // divide convert by 2, get only a 1 or 0

[Code] ....

View 13 Replies View Related

C/C++ :: Reading Number In CPP Program With Scanf

May 17, 2014

I'm using scanf() function to read numbers in my cpp program and, for example, if i want to read a string that is a complete name i could use

scanf("%[^]", x);

or if i want to read only vogals i could use

scanf("%[aeiou]", x);

Is it possible to read only positive numbers or only negatives numbers using scanf() and how to do it?

View 9 Replies View Related

C/C++ :: Program To Print Out Binary Value Of 16 Bit Number

Sep 22, 2013

Write a program to print out the binary value of a 16 bit number.

Create integers i, count, and mask.

Set 'i' to a hex value of 0x1b53.

Set mask to a value of 0x8000. Why?

print a line to show the hex value of i and then the leader for the binary value like this: Hex value = 1b53 Binary=

Use a for loop to loop 16 times and print 16 digits, using count as the loop counter

To test for each digit value, bitwise and 'i' with 'mask'

when the result for the bitwise and is true, print the number '1'

when the result for the bitwise and is false, print the number '0'

then shift mask one place to the right

print a new line and then quit

Use prtscrn and make a hard copy of the code with the console output.

Extra: use the modulus of count and print a space after every 4th digit to make the binary easier to read

The output should look like this: Hex value = 1b53, Binary= 0001 1011 0101 0011

so far this is what i have

#include <stdio.h>
#include <stdlib.h>  
int main() {
    int i, count, mask;
    //   1B53  0001 1011 0101 0011
    //   8000  1000 0000 0000 0000
    i = 0x1b53;

[Code] ....

it is telling me that there is an "else" without previous "if", also is the program that I wrote correct?

View 3 Replies View Related







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