C++ | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

C++

Hello guys, can anyone here help me to solve the first C++ project. This is my first time experience in programming and I don’t know what to do or how to start it

22nd Dec 2020, 7:28 PM
Omar Saad
Omar Saad - avatar
21 Answers
+ 12
Learn C
7th Feb 2021, 7:07 AM
Melekte Petros
Melekte Petros - avatar
+ 6
Omar Saad can you show your code?
22nd Dec 2020, 8:39 PM
Sonic
Sonic - avatar
+ 5
Abol thank you brother
22nd Dec 2020, 8:36 PM
Omar Saad
Omar Saad - avatar
+ 5
No need to learn c before c++ .. just focus on 1 Language and do practice sidewise .
25th Dec 2020, 2:42 AM
Ariv Lamba
Ariv Lamba - avatar
+ 4
Follow the C++ tutorial carefully.
22nd Dec 2020, 8:31 PM
Sonic
Sonic - avatar
+ 4
Sonic I wrote the code and my answer is exactly as the example in the project, but it still gives me that my answer is wrong, I don‘t know how to do it
22nd Dec 2020, 8:36 PM
Omar Saad
Omar Saad - avatar
+ 4
Me khud nai hu mere ko khud ko samjh nahi aaraha hai ki is ko use kysy kro...
23rd Dec 2020, 1:59 PM
Ümmãì Årshî
Ümmãì Årshî - avatar
+ 4
#include <iostream> using namespace std; int main() { //your code goes here int a; cin>>a; cout<<50-(a%50); return 0; }
23rd Dec 2020, 11:58 PM
Melekte Petros
Melekte Petros - avatar
+ 4
Mohammad sefatullah plz don't spam here.
24th Dec 2020, 11:21 AM
SKS
SKS - avatar
+ 4
Martin, thats true... if/else needs to be added in that instance x = Passengers % 50; If(x == 0) then... Else....
24th Dec 2020, 1:25 PM
Giovanni
+ 3
Sonic yes off course, but do you know the project?, if you know it i‘ll copy my code here to show it to you and if there is any mistakes you can help me to correct it
22nd Dec 2020, 8:53 PM
Omar Saad
Omar Saad - avatar
+ 3
Omar Saad well if it's a long project I'm not sure. If it's a small code snippet, maybe.
22nd Dec 2020, 8:54 PM
Sonic
Sonic - avatar
+ 3
sonic has everythin right however i would make 1 change, try Int left = max - remaining Or 50 - remaining after input goes through modulus ofcourse like sonic said
22nd Dec 2020, 11:39 PM
Giovanni
+ 2
Sonic no it is a very small project but I cant solve it yet, it shows how much I‘m unexperienced, here is the code this is the project: You are making a program for a bus service. A bus can transport 50 passengers at once. Given the number of passengers waiting in the bus station as input, you need to calculate and output how many empty seats the last bus will have. Sample Input: 126 Sample Output: 24 Explanation: The first bus will transport 50 passengers, leaving 126-50=76 in the station. The next one will leave 26 in the station, thus, the last bus will take all of the 26 passengers, having 50-26=24 seats left empty. this is my code: #include <iostream> using namespace std; int main() { //your code goes here int maximum = 50; int npass; std::cout << " Enter the number of passengers \n"; std::cin >> npass; int remaining = npass%maximum; int left = remaining - maximum; std::cout << " The of left empty seats is: " << left << std::endl; return 0; }
22nd Dec 2020, 8:56 PM
Omar Saad
Omar Saad - avatar
+ 2
#include <iostream> using namespace std; int main() { //your code goes here int n, empty_seat; cin>>n; //maxmium passenger that can travel in bus is 50 if (n <= 50) { empty_seat = 50-n; cout<<empty_seat; } else { n = (n%50); empty_seat = 50-n; cout<<empty_seat; } return 0; }
24th Dec 2020, 5:38 AM
Ariv Lamba
Ariv Lamba - avatar
+ 2
7
24th Dec 2020, 4:11 PM
Guddu Shakya
Guddu Shakya - avatar
+ 1
You should learn c language first.
24th Dec 2020, 4:28 PM
Rajpal Singh
Rajpal Singh - avatar
0
#include <iostream> using namespace std; These thing are important in the first
30th Aug 2021, 6:09 AM
Nafisa Mondal
Nafisa Mondal - avatar
0
gfvycfygtucudcufulit
20th Mar 2023, 10:32 AM
asliddin rasulov
asliddin rasulov - avatar