Posts

Showing posts with the label C Programming

What is the difference between break and continue statement? Explain with exemple.

The break statement is used in the loop to terminate the iteration of the loop. At the vary point the break statement is encountered the loop terminates. But in case of continue, when it is encountered, the control of execution ignores the remaining statements in the loop and starts execution from the very beginning statement of the loop. Example for break statement:     int i;     for(i=0;i<=10;i++){     printf("%d",i);     if(i==3)     break;     } Output: 0 1 2 3 When if condition becomes true, the loop terminates. Example for continue statement:     int i;     for(i=0;i<=10;i++){     if(i==3)     continue;     printf("%d",i);     } Output: 0 1 2 4 5 6 7 8 9 10 When if condition becomes true continue is  encountered, the loop ignores the remaining lines in the loop. So 3 has not been printed.

What is The Difference Between Declaration And Definition of a Variable/Function?

Declaration of a variable/function simple declares that the variable/function exists somewhere in the program but memory is not allocated them. But the declaration of a variable/function serves an important role. And that is a type of the variable/function. Therefore, when a variable/function is declared, the program knows the data type of that variable. In case of function declaration,   the program knows what are the arguments to that functions, their data types, the order of arguments and the return type of the function. So that’s all about declaration. Coming to the definition, when we define a variable/function, apart from the role of declaration, it also allocates memory for that variable/function. Therefore, we can think of definition as a super set of declaration. (or declaration as a subset of definition). From this explanation, it should be obvious that a variable/function can be declared any number of times but it can be defined only once. (Remember the basic principle ...

Definition of C

C  is a high-level and general-purpose  programming  language that is ideal for developing firmware or portable applications. Originally intended for writing system software,  C  was developed at Bell Labs by Dennis Ritchie for the Unix Operating System in the early 1970s.