Posts

Showing posts with the label Differences

Differences between Break and Continue | C Programming

Differences between Break and Continue in C Programming The major difference between break and continue statements in C language is that a break causes the innermost enclosing loop or switch to be exited immediately. Whereas, the continue statement causes the next iteration of the enclosing for, while, or do loop to begin. The continue statement in while and do loops takes the control to the loop's test-condition immediately, whereas in the for loop it takes the control to the increment step of the loop. The continue statement applies only to loops, not to switch. A continue inside a switch inside a loop causes the next loop iteration. Practically, break is used in switch, when we want to exit after a particular case is executed; and in loops, when it becomes desirable to leave the loop as soon as a certain condition occurs (for instance, you detect an error condition, or you reach the end of your data prematurely). The continue statement is used when we want to skip one

Differences between Puts and Gets in C Programming | C programming

Differences between "puts" and "gets" in C Programming We can read a string using the %s conversion specification in the scanf function. However, it has a limitation that the strings entered cannot contain spaces and tabs. To overcome this problem, the C standard library provides the gets function. It allows us to read a line of characters (including spaces and tabs) until the newline character is entered, i. e., the  Enter  key is pressed. A call to this function takes the following form: gets(s); where s is an array of char, i. e., a character string. The function reads characters entered from the keyboard until a newline is entered and stores them in the argument string s, The newline character is read and converted to a null character (\O) before it is stored in s. The value returned by this function, which is a pointer to the argument string s, can be ignored. The C standard library provides another function named puts to print a string on the display. A

Differences between Structure and Union in C | C programming

STRUCTURE IN C A structure is a user-defined data type available in C that allows to combining data items of different kinds. Structures are used to represent a record. Defining a structure:  To define a structure, you must use the  struct  statement. The struct statement defines a new data type, with more than one member. The format of the struct statement is as follows:    struct [structure name]    {        member definition;        member definition;        ...        member definition;    }; UNION IN C A union is a special data type available in C that allows storing different data types in the same memory location. You can define a union with many members, but only one member can contain a value at any given time. Unions provide an efficient way of using the same memory location for multiple purposes. Defining a Union:  To define a union, you must use the  union  statement in the same way as you did while defining a structure. The union stateme