26.1 C
Chennai, India
Tuesday, January 25, 2022 05:17 PM
C++

## Finding Decimal Equivalent of a Binary Number

Hi there,

I am learning coding in C++. I would like to start, by making a full functional calculator.  All of them are pretty done but I want some more options which are present in a scientific calculator, like binary calculation.  I don't see any function for this. So I guess I have to make one.

I have been trying to add the binary to decimal conversion. I know that the basic process is:

But how do I take the digits 1 at a time.  Should I take the binary number as a string or by integer? Please help.

• 1062 views

## Traversing a Relation Graph with DFS

Hello Everyone,

I have created a connected graph, where each node represents some fact. The centre is the point of start. You may think of it as a mind map. I want to search the map in a Depth First Manner. I understand the concept but don't know how to apply it. Here is a pseudocode

dfs(vertex v)
{
visit(v);
for each neighbour w of v
if w is unvisited
{
dfs(w);
add edge vw to tree T
}

• 1273 views

Hi,

I am doing some analytical program in C++ involving a lot of prime numbers. I don't think checking a number every time, whether it is prime or not would be a good idea.

So I just thought that if I could pre generate all the prime numbers in a list.

But it is taking too much. Time.

vector<int> prmn;
For (int i=2; I<100000; ++i)
If (isprime (I)) {
prmn.push_back(i);
}

Almost 4-5 second. I hate to find it upto 1000,000.

Is there any better way?

• 1353 views

## Need code for writing a class

Write a class to input the name of student and marks of three subjects, calculate the total marks as well as average marks. Each subject has a maximum of 100 marks.

• 956 views

## BFS concepts, search in a Graph

Hi.

I am trying to understand this code:

• 1134 views

## How to represent a graph in a C++ program logically?

Hi there.

I am just beginning to learn some C++ programming. It is quite interesting and flexible. I think it is a good habit to understand algorithms through implementing them in code. I studied some ways to represent graph in the computer. It seems to me that adjacency matrix is most simplest.

I have heard that they take a lot of space. My question is, how do I use adjacency list to reduce this memory consumption? Do I have to allocate the array size dynamically during runtime? How do I do it?

Is there any simpler way to manage adjacency list?

• 2833 views

## Compiling a C++ program from java

Hi,

Thank you for reading my post. I am making a simple IDE for C++.  I have a compiler installed. I created a IDE like text editor where I can type my code and save it. Now I want a button which can compile the code on click and output the result. How do I do it? Is there anything as simple as system() in C++? I have googled for system() in java. But not much of a success.

Thanks again.

• 1292 views

## Trouble with OpenCV. Load a image

Hi.

I am a student of CSE. I am doing some project using open CV. I need to load a image and save each of the regions predefined in the program, as a separate image. How do i do it in C++?

For example, suppose I have a form with 8 fields, I shall give the pixels from where to crop and the lengths along with it.

The program should crop the image according to the location.

• 1564 views

Hi,

• 1428 views

## Interfacing a robot arm with C++ in linux.

Hi,

I recently built a Robotic Arm to move objects by human Control. The model was fine and effective. So my new partner who is an Image Processing expert wants to work as a team to expand it.

The problem is, he is on Linux. I don’t know much of Linux. So is there any way I can interface the controller with a PC running Linux, using C++?

The current design uses a small keypad, having 12 keys to control the arm(8) to move (4) to up/down/hold/leave . Each of them generating a 8 bit signal. All I need is to generate the signal from a PC rather than a Controller pad.

• 1272 views