+ 3
Plz explain the code ? And first line output is coming Enter a number0 , I want to remove 0 how can I remove it
#include <iostream> using namespace std; int main() { int num ; int line = 1 ; cout << "Enter a number" << num ; cin >> num ; while (num<=0) { cout << "Number line" << num << endl ; } while (num>0) { cout << "\nLine number" << num ; num -- ; line ++ ; } return 0; }
24 ответов
+ 2
cout << num; outputs num value. It is still not assigned any value in your code so puts 0 as default. If you don't want to display, don't write it.
Just write :
cout << "Enter a number : " ;
Your first loop is an infinite loop. Remove first loop. Why need it?
+ 2
https://www.w3schools.com/cpp/
This is the best app i used to it
+ 2
Just remove the num variable written in the line with cout<<"enter a number"
Here as you haven't declared num to 0 but ide already assumes that num =0 for the very first case, when you take the value from cin then it updates the value, thus as you haven't declared any value and want user to input the value then you should not write num variable in the cout because you haven't took the result from user yet, and thus it's showing 0 in first case
+ 1
Thanks you very much Sakshi Mam
+ 1
#include <iostream>
using namespace std;
int main() {
int num = 1;
int number ;
int total = 0 ;
while (num<=5) {
cin >> number ;
total+=number ;
num++ ;
}
cout << total << endl ;
return 0;
}
PLZ explain this code also as I don't understand it also
+ 1
Please learn c++ on Sololearn and try to solve the code step by step and then you don't need to ask again why the code will not run because when you learn the code and practice it then you can solve the code without any error and please don't mind
+ 1
I practice it but after some time I forget the code | How can I manage this problem as I don't remember the code . Also can you plz suggest me some other You tube channel or site where I can learn c++ deeply
+ 1
Practice the code and make the handwritten notes and then practice in any software when you understand the code don't see the code try to solve by own
When you try to solve code by own assume that adding the two numbers
Now think how can I add two numbers through c++?
Now, I want two numbers store the two numbers in two variables, when you try to logic how can I make then you can solve easily and if you need or confusion or any problem then you get the help on internet hope it's clear to you
+ 1
Keshav Karn
Can you add what lines you don't understand? So that it helps to understand your understandings and problem..
May you are trying like but You don't have to understand code by code. You need to understand how the statements inside code works.. Each different blocks are explained in lesson separately.. So revise lessons one more time then try attempt again.
Your asked code takes 5 inputs ( from num = 1 to 5 inclusive ) by loop and adds to the total. Finally displays total.
+ 1
JayaKrishna
Thanks you sir for encouraging and motivation
+ 1
Thank you Sakshi Mam for giving this site I will learn , if any problem come then I will ask to both of you
+ 1
#include <iostream>
using namespace std;
int main() {
int num ;
int line = 1 ;
cout<<"Enter a number";
cin >> num ;
while (num<=0) {
cout << "Number line" << num << endl ;
}
while (num>0) {
cout << "\nLine number" << num ;
num -- ;
line ++ ;
}
return 0;
}
+ 1
Thanks you very much Anjana didi
+ 1
Keshav Karn
73 YouTube tutorials in a playlist, many of the same lessons as Sololearn:
https://youtube.com/playlist?list=PLAE85DE8440AA6B83
0
I even not understand , plz explain in detail Sir , line number 6 , 13 | and why taking num-- and line++ both
0
I solve you code and explain the code hope it's clear to you
https://code.sololearn.com/c4wjUeV6Jv7L/?ref=app
0
This code is complicated to you if you have not knowledge c++
0
I am learning c++ since 2 days
0
Plz tell me platforms , You tube channel to learn c++ in deeply ?
0
c