TRENDING NEWS

POPULAR NEWS

Can Someone Explain This Short Block Of Code Line By Line C Language.

How should I explain this C code line by line?

Sorry but your question is wrong. because you have not declare 'a' so first declare 'a' then there is worth meaning of the program. editedThe #include is a "preprocessor" directive that tells the compiler to put code from the header called stdio.h into our program before actually creating the executable. By including header files, you can gain access to many different functions--both the printf and getchar functions are included in stdio.h. conio.h header used in c programming contains functions for console input/output here you use  clrscr to clear the screen.void main():-This is the main function from where execution of any C program begins. And Void is used for no return value.{ :-This indicates the beginning of the main function.int arr[10], i :-An array of name arr, is declared of size 10, another integer variable  is 'i'.clrscr():- Clear the output screen.A for loop from i=0 to i<=9 with an increment of 1 each time is run. The loop will run 10 times i.e. for i=0,1,2,3,4,5,6,7,8,9.due to  printf() function, the statement "Enter numbers" is printed with a new line character in beginning. This statement will get printed for every value of i until the condition will become false.with the help of scanf() function, integer input is taken from the user corresponding to every value of array arr[10] from arr[0] to arr[9] because the base address of array starts from 0.Again a for loop from i=0 to i<=9 with an increment of 1 each time is run. The loop will run 10 times i.e. for i=0,1,2,3,4,5,6,7,8,9.Due to this  printf() function, the integers contained in the array are printed with a new line character at the beginning, from arr[0] to arr[9]. that is:-                           1st value                            2nd value                             3rd value                             .                             .                               .                             till 10th value.12. getch():-This command waits for any character input from keyboard.13. } :-This indicates the end of the main function.14. ; :-The semi-colon shows that it is the end of the command.

What is the code for leaving space in C language?

The space bar works pretty well.

What are the uses of comments in the C programming language?

That was already said before.But Comments can be used for several reasons.On really large projects sometimes classes, objects, methods are not well named.So usually on a large project with several files is good to have a comment explaining what each file does at the beginning.Comments are also used to explain assumptions, like #define MAX_BUFFER_SIZE 256.. Ok, why?. Now imagine that//Audio buffer is limited to 128 bytes, we need to guarantee no latency between them, so we use the other 128 bytes to keep a "circular buffer"
#define MAX_BUFFER_SIZE 256 //Wayy better no?
Sometimes to explain how values are being calculated or why we use something that at first glance is not what is expected but upon further analysis the solution is right. Basically you want to use a value X but upon further inspection Y is better…. this helps to prevent the next developer to spend a lot of time trying to go to the same conclusion as you. (yep it went back to 1 , not to 3 :( )Cryptic code like bit shift, binary operations, pointer arithmetics and other really weird stuff.Basically comments help the developer not to lose time thinking on what was already thought. It makes no sense to spend hours, days to come up with a solution and not explain why and how some decisions were made. Like the MAX_BUFFER_SIZE there.You don’t comment A+B if anyone can understand why you are adding the two values but you do comment anything that takes time to understand or assumptions that are not easy to understand. Imagine if you opened your code for the first time, would you get what you wrote and understand why it was done that way?

Why hasn't Python programming language replace any of the most popular languages?

C++, C#, VB and Java when the syntax allows programmers to express concepts in fewer lines of code? All it takes to write a Hello World program in Python is;

print("Hello world")

Why is Python still a unpopular language? What is wrong with Python programming language ?

What is meant by the comment line in C++?

Comments are portions of the code ignored by the compiler which allow the user to make simple notes in the relevant areas of the source code. C++ Programming/Code/Style Conventions/CommentsBasically comments are those parts in a C++ program that are not executed by the compiler.While writing a program there may be many instances where the programmer has to explain what the code is exactly doing in simple language.While working as a team many programmers often work on the same code so for the convenience, programmers use comments.In C++ there are two kinds of comments: Comments which begin with ' // ’. While executing the program the compiler ignores the text written after // till the end of the text.For example::cout<<” Hello world”; //commentsThese comments are used for quick introduction to the program.2. Comment beginning with /*and terminating with */The /* and */ pair of symbols denotes a C-style multi-line comment. Everything in between the symbols is ignoredFor example:cout<<” pls upvote my answer”<

How can I comment on all the lines in the Python IDLE editor?

Why would you want to comment ON ALL the lines in a piece of code in the first place?There is nothing less useful or timewasting than spaghetti code OR extreme commenting that requires constant maintenance and updating without informing the reader of anything relevant eg:Code like thisx = xx + (x*g) - (yyyy-yyy)(I once employed someone who wrote this kind of stuff) even with comments is unmaintainable and a disaster just waiting to happen, but then so is this kind of thing:a = b + 3.5 //Add 3.5 to b and store it in ac = int(a/d) // find the integer resulting from a divided by dand so on, because the comments tell you nothing about what is going on in the code and just add noise.Comments should be sparse, point out why a particular piece of code has been used (eg you are relying on a defined side effect of a language feature that isn’t commonly used as a shortcut(, or explain why one particular algorithm has been chosen over another. Possibly to make reminders.However, most devs forget at some point to make the comments match the code after a number of revisions, so the fewer comments the better: less chance of misleading the next person to look at them!Hungarian notation etc are attempts to get round the technical debt of poor commenting, but then you can end up with ridiculously long function/variable names that render the code just as unreadable, especially if there are lots of functions with similar names. Makes programming all but impossible, no matter how talented, for people with dyslexia too.

I don't understand this line in C++?

What does this line do: for (int cnt=0; cnt!=pow; cnt++) result*=value;
The full program is:

#include "stdafx.h"
#include
using namespace std;
int main()
{
int value, pow, result=1;
cout << "Please enter operand:" << endl;
cin >> value;
cout << "Please enter exponent:" << endl;
cin >> pow;
for (int cnt=0; cnt!=pow; cnt++)
result*=value;
cout << value << " to the power of " << pow << " is: " << result << endl;
system ("pause");
return 0;
}

TRENDING NEWS