C++ () is a general-purpose programming language created by Bjarne Stroustrup as an extension of the C programming language, or "C with Classes". The language has expanded significantly over time, and modern C++ now has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation. It is almost always implemented as a compiled language, and many vendors provide C++ compilers, including the Free Software Foundation, LLVM, Microsoft, Intel, Oracle, and IBM, so it is available on many platforms.C++ was designed with an orientation toward system programming and embedded, resource-constrained software and large systems, with performance, efficiency, and flexibility of use as its design highlights. C++ has also been found useful in many other contexts, with key strengths being software infrastructure and resource-constrained applications, including desktop applications, video games, servers (e.g. e-commerce, web search, or databases), and performance-critical applications (e.g. telephone switches or space probes).C++ is standardized by the International Organization for Standardization (ISO), with the latest standard version ratified and published by ISO in December 2020 as ISO/IEC 14882:2020 (informally known as C++20). The C++ programming language was initially standardized in 1998 as ISO/IEC 14882:1998, which was then amended by the C++03, C++11, C++14, and C++17 standards. The current C++20 standard supersedes these with new features and an enlarged standard library. Before the initial standardization in 1998, C++ was developed by Danish computer scientist Bjarne Stroustrup at Bell Labs since 1979 as an extension of the C language; he wanted an efficient and flexible language similar to C that also provided high-level features for program organization. Since 2012, C++ has been on a three-year release schedule with C++23 as the next planned standard.
I was wondering whether it's possible to write a code in C++ that would be able to solve the Harmonic Oscillator:
\ddot{x} + \gamma x = F_{external}(t,x)
With different F function inputs... I thought about creating a function with if clauses, so for different inputs by the user, the force F...
Hi. I am trying to create a program that I will give the maximum range (1,...,max) from which to generate random numbers, and make it generate N=maxgen random numbers (which later I can use for example in another program). Below you can see the code I wrote:
#include <iostream>
#include <ctime>...
Hey, guys,
I would like to learn about programming in C++. Could you point out good pdf textbook or material about this? What about game programming, where should I really start? I would really appreciate the help. Thanks
Homework Statement
Hi there,
I wish to use Newton's Laws in conjunction with Euler's Method to model the motion of a planet around a star.Homework Equations
2nd Law
F = m*a
Law of Universal Gravitation
F = -G*M1*M2/r^2
The Attempt at a Solution
[/B]
First I combined the two laws above...
I finished a course in C++ about a month ago and I would say I am almost average in programming in it. I am decent at command prompt programs but I do not have too much experience with gui programs.I have gotten to for loops and objects/methods and I did not understand ifstream.ofstream too...
This is an example from a study guide I'm using at the moment in learning C++.
//Test whether a number is prime
#include <iostream>
using namespace std;
int main ()
{
int x, y;
bool factorFound = false;
cout << "Enter a positive integer: ";
cin >> y;
x = 2;
while (x != y &&...
Homework Statement
A kilogram is 1000 grams. Write a program that will read the weight of a package of butter in grams and output the weight in kilograms, as well as the number of packages of butter needed to yield 1 kilogram of butter. Your program should allow the user to repeat this...
I am trying to implement a graph and perform BFS on it in C++. Following is the code I have written so far:
#include <iostream>
#include <vector>
#include <list>
#include <queue>
using namespace std;
const int V=5;
vector<list<int> > a(V);
int BFS(int s)
{
int visited[V]={0}...
Hello, PhisicsForumsWe are a group of students from the Avans University of Applied Sciences. We're currently doing a project where we have to design and make a 3D pong console.
The idea of the project is to make a "Dedicated Video Game Console" that can be remotely controlled by remotes using...
Hi, is there any way to let my C++ program calculate some data and return them as results into a txt file?
For example let's say I want to make a txt with the following things inside:
Is it possible to write in C a program of the form:
and let it somehow extract each k[j] into the text?
Hi,
Apart from the Euler's method, is there any other method (with better efficiency) that can let us solve an Ordinary Differential Equation of the form \frac{dy}{dx}= f(x,y)?
Hi everyone
ın fact at the beginning ı want to select three points every curve Idid it But now I shold find which points ont the same time AND THEN I shold save its How can do it
My code is here
#include <iostream>
#include <iostream>
#include "opencv2/highgui/highgui.hpp"
#include...
Hey all. I am currently trying to brush up on my multithreading "skills" (I dare say) that I learned in my undergrad class. I have the following code that I am trying to run:
#include <pthread.h>
#include <iostream>
using namespace std;
void* func1(void*);
int main(int argc, char** argv){...
I'm currently working on a master's degree in physics where my project uses C++. I have read about how some physics phD's were able to get data scientist roles despite working on computational astrophysics. This is a little surprising to me since I thought experimentalists would be more suited...
I'm making a basic neural network, and I haven't programmed in an object oriented way since java in undergraduate. Everything lately has been c and fortran 77.
I have an object that is a "Network"
In addition to functions and locals, it includes a pointer to an array of another object "Layer"...
Hello again everyone! :)
I have been trying to implement K^(2^N) mod 10^9+7 in C++ where both K and N are integers and $1\le K\le 10^5$ and $1\le N\le 10^9$.
My idea is to use the fact that
$$a_n=K^{2^N}=K^{2^{N-1}}\cdot K^{2^{N-1}}=a_{n-1}^2$$
Following is the code I wrote...
This has been bugging me for a while. I suspect the answer is in Sutter or Meyers but I don't own them. Why do so many of the top C++ people say forward declaring templates is bad style or dangerous?
Hi All,
Not sure if this is the right place for this thread but it seemed like it was.
I have been trying for two whole days to get some plotting tools up and running that will work with my:
OSX 10.8.5, Xcode 5.1.
I have tried MathGL, Plplot, Gnuplot, Chplot, matplotpp, etc.
I get errors...
I've changed the Library Search Path to the folder that contains the file I'm trying to use, filesystem.hpp, and then including the file with the directive #include <filesystem.hpp>. I've also tried changing it to "filesystem.hpp"; changing the search to recursive; trying to grab it from the...
I came across this question while studying for a C++ exam. What is the screen output of the code?
#include <stdio.h>
int main(){
int i, counter=0;
for(i=0;i<100;counter++){
i++;
++counter;
}
cout<<i<<' '<<counter<<'\n';
return 0;
}
What will this code display...
I have my final exam for C++ tomorrow. I was studying a previous exam and I came across a certain problem that I would like to know how to do.
Suppose that we want to print out the following on the screen, please complete the code segment below by filling in the blanks
1
1 3
1 3 5
...
...
1 3 5...
I have been given a project to modify my pre-existing code to satisfy these guidelines:
- Create a file called "sides.txt" and put it in the same folder as your program.
- The file contains multiple lines with each line having the three sides, separated by white spaces, e.g.,
3 4 5
6 8 10
5...
I was given this problem a while ago to complete as a bonus but I wasn't able to do it. I just came across it and would like to know how it should be done.
Given an integer vector "vi" that is already sorted in ascending order (all elements of the vector are positive), write a function that...
Assign the first instance of The in movieTitle to movieResult.
Sample program:
#include <iostream>
#include <cstring>
using namespace std;
int main() {
char movieTitle[100] = "The Lion King";
char* movieResult = 0;
<STUDENT CODE>
cout << "Movie title contains The? ";
if...
A pointer in C++ is represented by *. Sometimes the * comes after the variable/class/whatever such as 'Pointer*'. Other times it comes before, '*Pointer'. What is the difference between the two?What is the member access operator for? (->) According to my notes, a->b is equivalent to (*a).b
I need some help understanding some things.
One, I understand WHAT pointers do but how are they useful and how/when are they necessary?
Two, what is the purpose of the flush function? This is the definition that I've been given: "The << flush forces cout to flush any characters in its buffer to...
Hello, I have the haversine function within my C++ program to calculate the distance between to points, the two tester points I have chosen are Swansea and Cardiff both located in Wales.
Swansea lat = 51.622559, long = -3.934534
Cardiff lat = 51.475661, long = -3.174688
The problem I am having...
Basically within my whole code is 4 major chunks of code that each loop repeatedly. The obvious problem is when I run it, it will get stuck on the first chunk and loop forever, therefore never moving on the next chunk. What I need is to have each section run for 10 seconds and then move on. Is...
going through problems to study for a test
Resize vector countDown to have newSize elements. Populate the vector with integers newSize down to 1. Ex: If newSize = 3, then countDown = {3, 2, 1}, and the sample program outputs:
3 2 1 Go!
Sample program:
#include <iostream>
#include <vector>...
im going through previous assignments to study for a test and i can't seem to remember how i did this one.
Add each element in origList with the corresponding value in offsetAmount. Print each sum followed by a space. Ex: If origList = {40, 50, 60, 70} and offsetAmount = {5, 7, 3, 0}, print...
Homework Statement
m working on a Engineering Project and I'm having serious trouble trying to run this program in C++. I'm following an example of the program from Program done in C but I'm trying to convert it into C++. I'm going to link the example I'm following and what I'm doing trying to...
Print person1's kids, apply the IncNumKids() function, and print again, outputting text as below. End each line with newline.
Sample output for below program:
Kids: 3
New baby, kids now: 4
Sample program:
#include <iostream>
using namespace std;
class PersonInfo {
public:
void...
Hi everyone! Fresh and new around here.
I just started learning C++ and wrote a program yesterday to list all primes up-to an input n.
It works just fine except for one problem. I tried listing all the primes up-to 100,000. Program completed in about 20 seconds, I scrolled up to the top but the...
I am reading a book called C++ primer, which mentions about a data type of C++ called char(Character). I know that this data type can hold characters such as "A" or "5". But what does signed and unsigned char mean?
The book says: "an 8-bit unsigned char can hold values from 0 through 255...
Can someone try compiler this and tell me what error you get and what it means? https://github.com/jamkin/CSS-Template-Generator/tree/master/CSS%20Template%20Generator
I get
Mod note: Removed the [ I ] tags and the [ color ] BBCode tags, and replaced with [ code ] tags. There were too many...
In this assignment, you are going to write a function called sortMe that sorts the elements of an array in numerical order from
highest to lowest values (descending order) or vice versa (ascending order).
The interesting point of the function is that sortMe does NOT re-arrange elements in the...
which loop is correct for reversing a vector? please help.
A.
for (i = 0 ; i < NUM_ELEMENTS ; ++i ) {
tmpValue = revVctr .at (i ) ;
revVctr .at (i ) = revVctr .at (NUM_ELEMENTS - 1 - i ) ;
revVctr .at (NUM_ELEMENTS - 1 - i ) = tmpValue ;
}
B.
for (i = 0 ; i < (NUM_ELEMENTS...
Program should compute the power x^2
#include<iostream>
int main() {
double x;
int n;
double pow=1;
cout<<"Please enter x:";
cin>>x;
cout<<"Please enter n:";
cin>>n;
LOOP FOR X^N
pow=pow*x
cout<<"The result is: "<<pow<<endl;
return 0;
}
as you can see, there is no math library included and i...
compute the area of a triangle. write an if/else statement to check if the three sides provide a valid triangle. to make a valid triangle, all sides have to be positive and the sum of any two sides must be greater than the third. add a while loop so that if the sides are invalid the user is...
Could someone comment on, or perhaps help me fix/simplify/optimize/elegantify, a function I'm trying to make to split a string by whitespace into a vector of strings, discounting any whitespace in quotes?
Intended behavior:
name="someName" class="class1 class2 class3" id="someId"...
Hello,
I am relevant new user to C++ while i am quit comfortable using fortran!
One of my favourite thing to use in fortran was the subroutines but i struggling to find something similar in C++. Let me give you an example:
In Fortan:
subroutine test(Tabular1,Tabular2)
...
...
Greetings all !
I have this problem with SGP4 propagation, that I hope someone can help me out with.
I acquired a TLE of the ISS from internet and used the C++ SGP4 propagator to compute future position and velocity vectors of the Station. I am unsure about some aspects of results though and...
Greetings all !
I really hope this is the right sub-forum for my question, I have chosen it because I've seen TLE being mentioned a couple of times around here.
I have done some reading on astrodynamics and orbital mechanics, but I am relatively new to coding. I would like to write some C++...
ok I am working on some activities and i can't get past this one.
Write a for loop to populate vector userGuesses with NUM_GUESSES integers. Read integers using cin. Ex: If NUM_GUESSES is 3 and user enters 9 5 2, then userGuesses is {9, 5, 2}.
Sample program:
#include <iostream>
#include...
ok so i realized my problem with c++ is that i don't really understand for loops. well it's not exactly the loop itself but i don't understand the loop variable [i]. what is for EXACTLY? why is it needed? why can't you just use the other variable you are using? why does this extra variable need...
Print numbers 0, 1, 2, ..., userNum as shown, with each number indented by that number of spaces. For each printed line, print the leading spaces, then the number, and then a newline. Hint: Use i and j as loop variables (initialize i and j explicitly). Note: Avoid any other spaces like spaces...
Homework Statement
the problem is to find the inverse of a 3x3 matrix using LU Decomposition with C++ command, with the numbers designated. in my case, my numbers for the matrix are
'306
410
780'
#include <stdio.h>
#include <iostream>
#include <stdlib.h>
#include <math.h>
using namespace std...