C++ programming tutorial basic structures tutorial ll

preview_player
Показать описание

Рекомендации по теме
Комментарии
Автор

bro using his phone to code 😭😭😭😭 times must be tough

hirw
Автор

mất vài phút mới hình dung ra đc cách thức hoạt động, cám ơn bạn rất nhiều ^^

minhtan
Автор

Thanks for the tutorial!
I liked the part where he explained it.

lloyd
Автор

DO NOT CODE LIKE THIS. BETTER EXAMPLE INCLUDED BELOW.

His code runs fine but if you're a beginner these are not the conventions you want to pick up. Here's what it should look like:

Note: text following // represents a comment
Ex: // this is a comment.

#include <iostream>
using std::cout;

// avoids use of magic numbers
const int PYMD_SIZE = 15;

int main( ) {

// pre incrementing "i" is a lighter
// process on the machine as
// opposed to post incrementing.
for (int i = 0; i < PYMD_SIZE; ++i) {
for (int j = PYMD_SIZE; j > 0; --j) {
if ( i >= j )
cout << " *";
else
cout << " ";
}

// endl flushes the stream each
// time it's ran and is
// unnecessary using newline
// is again lighter on the
// machine
cout << "\n";
}
return 0;
}


-use indentation

- avoid use of magic numbers
-const should be UPPERCASE

- if possible only define index variables inside the scope of the for loop when its importance is only needed while loop is running. In the video he defines them outside the loop scope and is unnecessary.

-if possible use pre incrementing for the index variables as opposed to post

- unless you need to flush the output buffer use newline "\n" as opposed to endl

pnuema.
Автор

Jab int i, j; ko inatilize kar hi liya hai toh loop mei int j= n karne ka kya matlab 🤔

sirjeelkhan
Автор

Bro I'm beginner and I don't know abc of this all, but maza aaya 😝, keep it up ✌️

littletiger
Автор

Which text editor u used for programming and which one is the best text editor for coding programing

forever
Автор

No way someone intializes i and j out of the for loop

bucinoulje
Автор

Здесь из прекрасного, только вывод и return 0;😅

donkix
Автор

I watch this video and over again to find out how the code works.
I'm a beginner programmer so if you could tell me the logic behind this program, that would be great 😃.

Kattukundanesports
Автор

Bro which programming setup are you use can you told me please

junedmulla
Автор

Another Easy and simple code to do the same

for (int i=1 ; i<=n ; i++){
for (int j=1 ; j<=n-i ; j++)
{
cout<<" ";
}
for (int k=1 ; k<=i ; k++)
{
cout<<"*";
}
cout<<endl;
}
}

farooqrajpoot
Автор

I do not understand the language but I think it is cool
keep it up

NodyTales
Автор

Redefinition of j? No indentation? Also what is a code writter?

simplyacatenjoyinglife
Автор

make same trangle shape function recursion method se

problemslover
Автор

Hello bhaiya mera expression error bata Raha hai please reply

Satyendrapandey
Автор

Ufff muji bilkul smj nahi ata pre medical se Bs computer mi aya hu😢😢😢😢

abdurrehmankhanshinwarikha
Автор

Code in video did not work for me on a Windows machine running VS Code - To make it work I had to do the following:

I removed the second declaration of - just because
I added: printf("\n");



#include <iostream>
using namespace std;

int main()
{
    int n = 15;
    int i, j;
    for (i = 1; i<= n; i++)
    {
        for (j = n; j>=1;  j--)
        if (i>=j)
            cout<<" *";
        else
        cout<<" ";
        printf("\n");
    }

tonyvivaldi
Автор

it didn't work ... I'm not getting the same output

sadii
Автор

Just wondering why you initialized j two times 🌚

tirthankarroy