49,757 Topics

Member Avatar for
Member Avatar for C++.java

5. Write a program that adds up the squares and adds up the cubes of integers from 1 to N, where N is entered by the user: Upper Limit: 5 The sum of Squares is 55 The sum of Cubes is 225 Do this by using just one loop that …

Member Avatar for death_oclock
0
188
Member Avatar for nijju_31

[code] #include<iostream> #include<conio.h> #include<string> using namespace std; int main() { int i,len,t; cin>>t; char a[100],b[100]; while(t>0) { cin>>a; len=strlen(a);len=len-1; for(i=0;i<=len;i++) { b[i]=a[len-i]; } cout<<"value of a\n"<<a<<"\n"<<b; if(strcmp(a,b)==0) cout<<"YES"<<endl; else cout<<"NO"<<endl; t--; } getch(); return 0; } [/code] every time the loop runs the garbage value of char b; remains. . …

Member Avatar for Comatose
0
108
Member Avatar for confused_in_CO

Hello, I have been lurking on this site for a while, reading other people's programming questions and answers in the hopes that I'll learn something. I'm in my first programming class right now, and I think I'm confused about nested loops and how to keep a program looping until it's …

Member Avatar for confused_in_CO
0
76
Member Avatar for StandardsDT

I'm having some trouble with my while loop in my code. If I enter in 20 and then enter in 14 for the coupons I want to redeem, it goes into a constant loop and doesn't stop. However I did stop it from doing this by putting in a [icode]break;[/icode]. …

Member Avatar for StandardsDT
0
137
Member Avatar for k2k

My program should find any 4 letter words and change them into string "love" ... i have successfully found all the spaces and modified any 4 letter words before the spaces... however, the last word before the '/0' doesn't change... please help. btw, is there any string class function check …

Member Avatar for VernonDozier
0
127
Member Avatar for GadiK

Hi Guys, I'm trying to write a program (MFC) that while working displays a log to the user. For this log I thought I'd use an Edit Box because I can set it to be "multiline". What I had in mind is to display each new log entry in a …

Member Avatar for GadiK
0
970
Member Avatar for shahab.burki

Hi, Can we use structures within classes as data type? if yes then please give some examples? Thanks

Member Avatar for Comatose
0
77
Member Avatar for winrawr

How would I write a function with an undefined number of arguments? Like, how when using printf(), you write the string in the first argument and in the string use format identifiers. Then, for each format identifier you use is an argument specifying what should be put there in the …

Member Avatar for ArkM
0
437
Member Avatar for rudasi

Hi, I have been trying to figure this out and I know it must be something simple but I cant get it. Why does the following code give an answer of 1. double a=8; cout<<pow(a,1/3); I would think it should be 2. Thanks

Member Avatar for rudasi
0
153
Member Avatar for friollano

hello, i need some help. i have an assignment that i need someone's opinion on. this is what the assignment is about: A soft-drink manufacturer produces several flavors of drink—for example, cola, orange, and lemon. Additionally, each flavor has several versions such as regular, diet, and caffeine-free. The manufacturer operates …

Member Avatar for VernonDozier
0
80
Member Avatar for Innercoder76

Hey everyone, I need help with my program it is an ipod simulator that goes like this: [CODE]/* FUNCTION - void initaPod Initialize all the slots to blank and 0 size memory*/ void initaPod (); /* FUNCTION - int addSong attempts to add a new song to the aPod returns …

Member Avatar for ArkM
0
97
Member Avatar for azwraith69

hello everyone.. thx for droppin' i need to write a program, a recursive sudoku solver and this is what i have so far... [B]main.cpp[/B] [icode] #include <iostream> #include <vector> #include "sudoku.h" using namespace std; int main() { vector< vector<char> > rows; // Load grid rows=load(); // Check if grid is …

Member Avatar for azwraith69
0
154
Member Avatar for Stefano Mtangoo

Please anyone help me on classes. I have written this class example and keep getting error on that the function is private. I though variables in functions are private but mmh, I think I'm wrong. Can anyone clarify how to rectify this? Also, could you explain to this New Bee …

Member Avatar for Stefano Mtangoo
0
83
Member Avatar for shamila08

Hello! here c++ program. my problem is i need to find the permutation is even and odd. However the value +1 (even )and -1(odd) is not appear for each permutation. [code=cplusplus]= #include <stdio.h> #include <stdlib.h> #include <iostream> #include <memory.h> #define MAX 100 char num[MAX + 1]; int n; using namespace …

Member Avatar for shamila08
0
110
Member Avatar for Xtreath

First of all hi to evryone. I tryed to make a exe work on most pc's but it only works on mine. My friends got a error when they try to run it. "The application cannot be started because the configuration of the application is wrong. ( or something like …

Member Avatar for cikara21
0
77
Member Avatar for mattwaab

hey, i am working on this project, and have made it to the end of the hard coding part. Now i need to work out the bugs / get the thing to compile. I am having some trouble though as i am getting error messages that i dont understand. here …

Member Avatar for StuXYZ
0
94
Member Avatar for billchow24

How can I read integer by ifstream from a file 2 3 -5 9 -6 Besides, how can I read the negative sign also? Thanks everyone!!

Member Avatar for Ancient Dragon
0
56
Member Avatar for KarthikOnIT

Hi, I m trying create a COM Server EXE(C#) from my VC++(dll). The problem is when my dll is in Admin privilege and when i try to do a CreateInstance of my C# EXE it's created with same privilege(admin). I m trying to figure out how to Create my COM …

Member Avatar for Ancient Dragon
0
79
Member Avatar for winrawr

So I got past my last problem using new[], but now I seem to have a new one... I created a char***, var. The goal was to build each dimension of the array to be different sizes at different times, based on separate user input... Here is the code: [code=cpp] …

Member Avatar for Sky Diploma
0
250
Member Avatar for Himerz

Well people... I already know that c++ is not what I want to do in the future, but I do have to pass this class. That said, I need help with this array. I understand how they work, but my instructor wants us to use them in a function!!!!! I …

Member Avatar for Himerz
0
105
Member Avatar for JAGgededgeOB172

Hi, I'm having issues with a program that concept-wise sounds very simple. The program should read in data from a text file (attached a2.txt), and perform stack and queue operations upon the data. The data consists of long math problems, dealing with order-of-operations. The correct output that should be appearing …

Member Avatar for JAGgededgeOB172
0
213
Member Avatar for StandardsDT

I have a few assignments to get done, but I figured I'll post one to see if I'm the right track. If so then what I did will greatly help me. Here are the requirements [quote]Create a simple Dog class that has the following private fields (age (int), gender(char), name(string), …

Member Avatar for StandardsDT
0
149
Member Avatar for kjiu

Hello, I have a problem (error) the error is : [QUOTE]a.c:354: error: ‘hton1’ was not declared in this scope [/QUOTE] and the code is : [url]http://wklej.org/id/52405/[/url] What is wrong ??

Member Avatar for ArkM
0
68
Member Avatar for ajkraft21

I have been giving the task of making a box using all asterisks, given an input of say 5. Im supposed to make something that resembles a 5x5 box with nothing in between... I am stuck at a dead-end here and any help would be appreciated! My code so far …

Member Avatar for winrawr
0
129
Member Avatar for CPPRULZ

I just have one question, when you have a class that is defined: [code=C++] class box{ public: int *value; box() { value=new int; *value=0; }; box(box &c) {*value=*c.value;}; }; [/code] If in the main you said class box b(a); it would work as expected. But I don't understand how that …

Member Avatar for death_oclock
0
149
Member Avatar for krispygrimace

Ok, I know how to overload an operator. I have successfully overloaded +, -,=, * for a matrix class. I am trying to do inversion of a matrix. I have the code working for the inversion but I do not know how to properly overload the function I want. I …

Member Avatar for nucleon
0
95
Member Avatar for krispygrimace

I have written some code to dynamically allocate memory for a 2D matrix. I am using overload operator to perform functions on the matrix naturally. I am having memory issues (Unhandled exception at 0x... Access violation reading ...). Here is my class, header, and main code. The code builds fine …

Member Avatar for krispygrimace
0
168
Member Avatar for guest7

Hi, I wish to read the file twice. I am using ifstream to read the file. I tried using rewind(File pointer). But i get an error. How can i do it. Thanks

Member Avatar for guest7
0
2K
Member Avatar for dmkp

Hi, I've wondered this for some time now. Say function A() returns a char* which points to a string.. obviously Say function B(char* szString) takes a char* as its argument. If I call B(A()).. is the string automatically deleted or will it create a memory leak? Thanks

Member Avatar for Narue
0
72
Member Avatar for daviddoria

A friend convinced me to store a vector of pointers in my class: [code] vector<Point*> Points; [/code] In my class instead of a vector of "real" objects (what do you call this?). The problem now is that there are several functions (out of my control ie. in a library) that …

Member Avatar for Narue
0
113

The End.