429 Posted Topics

Member Avatar for faisaly
Re: C++

Dear All, Kindly help me regarding this questoin of C++(OOP). Write a template function that returns the average of all the elements of an array. The arguments to the function should be the array name and the size of the array (type int). In main(), exercise the function with arrays …

Member Avatar for RenjithVR
0
263
Member Avatar for vsha041

You could do something like [code] system("cc -c test.cpp | tee out.log") [/code] or [code] system("cc -c test.cpp >> out.log") [/code]

Member Avatar for Agni
0
333
Member Avatar for QuantNeeds

i dont think you should assign a char inside double quotes. Try play[2] = '*' if (play[2] == '*')

Member Avatar for QuantNeeds
0
76
Member Avatar for ub007

From the package Manager you can install 'DrPython' . It's a neat IDE for writing/debuggin/executing python scripts.

Member Avatar for AceofSpades19
0
101
Member Avatar for megazear7
Member Avatar for Vallnerik25

One more way is to use a single dimension array. You can as easily take all the inputs from the users and then declare a single dimension array dynamically, size would the product of the the dimensions. and then while accessing the elements you can use pointer arithmetic. something like: …

Member Avatar for Vallnerik25
0
108
Member Avatar for krazineurons

hex2bin[h] will give the value for the key 'h'. i executed each statement separately, without declaring the dictionary and the output will make things very clear to you [code] >>number=1000 >>for h in '%X'%number: print h 3 E 8 [/code] now you can see that 'h' gets values 3,E,8. All …

Member Avatar for krazineurons
0
157
Member Avatar for bjaanes

The size of the array has to be known at compile time. If it has to be decided at run-time please use dynamic arrays. When you used #Define the size was known at compile time hence it worked.

Member Avatar for Nick Evan
0
147
Member Avatar for himsymcpp

Can you post the code if possible. also a sample file or a snip of the data in file.

Member Avatar for himsymcpp
0
266
Member Avatar for crioto

Algo will be: 1>divide the number by 10. 2>print the remainder or store it in an array. 3>assign the quotient as the original number and loop steps 1-2-3 till quotient it less than 10 4>print the last digit or store it. Now you should have each digit.

Member Avatar for crioto
0
89
Member Avatar for Noxes

There's a thread in this forum, 'c/c++ faqs and practice problems', right on top, you can try to solve the problems mentioned in that.

Member Avatar for Alex Edwards
0
98
Member Avatar for QuantNeeds

Where is 'Status' defined?? .. Basically 'Status' is not a native Datatype of c++ and so it doesnt have a predefined '==' operator for it. So you need to overload the particular operator before you do something like Status == xxx. Read more about the topic "Operator Overloading" and you …

Member Avatar for QuantNeeds
0
2K
Member Avatar for lAmoebal

2 1/2 years for me .... and i realise that it'll take me time to be a pro in c++ . In contrast i see people who use Java become proficient much quickly. There was a time i was thinking of shifting to Java(around a year back) but then stuck …

Member Avatar for stephen84s
0
364
Member Avatar for Agni

Hi, I have 2 modules, grepforapp.py and myApp.py. Basically i'm trying to make a 'search' utility. myApp makes the UI with one textbox for taking input, start button and a list box which displays the file names where the pattern was found. grepforApp walks through the dir tree and searches …

Member Avatar for woooee
0
197
Member Avatar for Aamit

This code is not even compiling. If you can post the correct-compiling code i can try to find the problem.

Member Avatar for Nick Evan
0
178
Member Avatar for radnik

if you want to pass a 'Paths' type to 'distance' you simply have to call like this [code]distance(trajectories)[/code] since trajectories is of type 'Paths', in the definition you will say [code]double distance(Paths trajectory){}[/code]

Member Avatar for jencas
0
120
Member Avatar for fishwater00

malloc allocates memory and returns a pointer to the beginning of that block of memory. You need to assign it to some pointer not an object as you are doing here. Change that to pointer and it should work. i couldnt really understand your 2nd qs, would be helpful if …

Member Avatar for fishwater00
0
257
Member Avatar for agrawalashishku

you can put the sumAll function in baseClass. The printAll can be made virtual and also moved to base class. This way you can sum up the values in base(since both are int's) and then print the correct message out. i'm not sure why you're using so many static's and …

Member Avatar for jencas
0
77
Member Avatar for Agni

Hi Guys.. Can someone explain to me what's the difference between sending any data over a socket vs sending an http request? i mean sending an http request would also be happening over a TCP socket, am i right? so basically it's as simple as sending data from client socket …

Member Avatar for tzushky
0
714
Member Avatar for Agni

Hi, When i search for a pattern in a file how do i get the line and line#? basically i want to replicate the 'grep' command functionality. Now i can easily say whether the pattern exists or not using re.search funtion but i'm not able to print that particular line …

Member Avatar for Agni
0
125
Member Avatar for WillMcc

You need to include the file which declares cout,cin i.e. #include <iostream> and namespace 'std'. i dont think you need the stdafx.h at all. and please read the welcome guide to understand the posting rules and regulations.

Member Avatar for WillMcc
0
135
Member Avatar for Aamit

Even then output might not be what you desire, getc returns the character currently pointed and also advances the position indicator by 1. so it'll always stub the first char from the output. since you're already checking for the 'eof' you dont need this extra check using getc. You can …

Member Avatar for mitrmkar
0
110
Member Avatar for imtnan

> 2) tell the function the number of each dimension's element. > > `void function(int& aaa[][], int 1d, int 2d)` > you dont need to say `int& aaa` just `int aaa` will be enough, also i think that you will have to give the 2nd subscript of the array `int …

Member Avatar for dougy83
0
3K
Member Avatar for zoner7

It could just hang waiting for some input which it's not getting, in that case we need to check the time elapsed and restart the program. Frankly speaking i cant think of a way to do it rt away, and i'm in a little hurry, but this was just to …

Member Avatar for Ancient Dragon
0
120
Member Avatar for Agni

Hi, We're using curses library functions to draw windows in our project. For showing an error the error message is enclosed within '-'s , it seems to be working fine till we ported to a new linux machine where its displaying some garbage instead of the '-' . To be …

Member Avatar for Duoas
0
117
Member Avatar for brk235

well you cant really name the elements of an array, they need to be accessed using the subscript.However to identify each object you can add a unique field in the class and set it for each object. Then when you fetch the object just check for that value to identify …

Member Avatar for vijayan121
0
105
Member Avatar for WondererAbu
Member Avatar for Aamit

I feel that for talking between different processes you will need to use CORBA(Common Object Request Broker Architecture). Atleast that's how we do it here, there might be other methods though. So basically what happens is, your servers register with the broker. Client request for the server object from broker. …

Member Avatar for Agni
0
111
Member Avatar for n.aggel

>>I.e. if we open a text editor will we find threads inside? Text editor will definitely be multithreaded. Imagine a scenario where you send one document for printing and are writing into another document. Almost every application we use in our day to day lives will be multithreaded. The fast …

Member Avatar for n.aggel
0
173
Member Avatar for savinki

1-> What is the expected output? 2-> What's the output you're getting right now? 3-> Post the complete code 4-> Please use code tags to make you're code readable

Member Avatar for Agni
0
101
Member Avatar for nurulshidanoni
Member Avatar for StrawberryChips

i'm trying to execute this program and everytime it tells me the same thing.. [quote] Welcome to the imaginary drink machine! Please choose your icey cool beverage!! --------------------------------------- 1. Cola $0.75 2. Root Beer $0.75 3. Lemon-Lime $0.75 4. Grape Soda $0.80 5. Cream Soda $0.80 6. Nothing thank you …

Member Avatar for Agni
0
333
Member Avatar for blackhawk9876

hi..can you please post the 'correct' version of code using code tags and also the errors in one single post. That ways it'll be easier for people who want to help.

Member Avatar for William Hemsworth
0
181
Member Avatar for rem0404

The definition can be in any file, since its not a class member. your code seems fine to me. inside the defintion, you can decide what all you need to output when you do cout << book. [code] ostream& operator <<(ostream& outs, const Book& b) { outs << b.publisher << …

Member Avatar for Lerner
0
109
Member Avatar for hezfast2

mostly this type of error comes when you are trying to access an index which doesnt exist in the vector. suppose you have only 5 elements in the vector and you try to fetch [5] or [6] element. in your sellstock method you are looping from 0-6, can you check …

Member Avatar for littlestone
0
404
Member Avatar for Agni

Hi Guys... i'm not so good at oracle, sql and related stuff.. but i do need to write some simple query's from time to time and i do need to understand that which all tables get updated by a particular transaction. I can do that by going through the code, …

Member Avatar for alit2002
0
96
Member Avatar for Agni

Hi.. i have installed Ubuntu 7.10 on my laptop. it also has windowXP installed. i'm able to access wireless network on windows but on ubuntu its not detecting it. when i connect it through a wire i'm able to access. i read on the net, seems my WAN card which …

Member Avatar for riccio
0
91
Member Avatar for EBC
Member Avatar for replyfast
Member Avatar for Kyouya

i guess your first file should have these 2 lines "3 3 1 2 3 4 5 6 7 8 9" for a 3*3 matrix 1st line of the file gives you the number of rows(3) and number of cols(3) and the second line is givng row*col numbers. hence a[0][0] …

Member Avatar for Agni
0
141
Member Avatar for rje7

doesnt seem good to me ... why is the base class named 'life'? and why does 'life' have a member function called 'eats' ? and then you have 'producers' and 'animals' deriving from life.. you might have some explanation for all the names and member functions. but you should always …

Member Avatar for rje7
0
199
Member Avatar for Agni

Hi.. whats the best way to initialize a char* ? i tried using char* p = ""; and it gives segmentation fault at times. not sure how to initialize it. this is the function where i'm using it. screenReturnValue variable is not getting initialised properly everytime, when i call this …

Member Avatar for Agni
0
15K
Member Avatar for Agni

Hi Guys.. is there someway i can change my screen name from 'chandra.rajat' to something else ??... -chandra

Member Avatar for William Hemsworth
0
331
Member Avatar for c++noobie
Member Avatar for timdog345

[QUOTE=Rajith Cherian;587065]The code could look like [CODE] if ( ( i%2 ) == 0 ) { nEvenSum += i; //Sum of even Numbers } else { vOddNumber.push_back(i);//Storing all Odd Numbers nSumOddSquare += ( i*i ); // Sum of square of odd numbers } [/CODE] Hope this is your requirement[/QUOTE] incase …

Member Avatar for Rajith Cherian
0
109
Member Avatar for bballj32

just print out the array using 2 for loops. something like [code] int a[m][n]; cout << "Name" << " " << "Total" << endl; for(int i=0;i<m;i++) { for(int j=0;j<n;j++) { cout << a[i][j] << " " ; } cout << endl; }[/code] do some formatting.

Member Avatar for Agni
0
281
Member Avatar for gazoo
Member Avatar for jmines

loads of examples available on this forum.. please use the search option.

Member Avatar for Agni
0
50
Member Avatar for Shinbuki
Member Avatar for jdphenix

The End.