Author: ERP Consultors
DO WHILE Loop in C Language: (1) Unlike the for and while loops, the do-while is an exit-controlled loop i.e. it evaluates its test-expression at the bottom of the loop after executing its loop-body statements. This means that a do-while loop always executes at least once. In other two loops for and while, the test-expression is …
WHILE Loop in C Language: (1) The while statement executes a block of code repeatedly as long as the control condition of the loop is true. The control condition of the while loop is executed before any statement inside the loop is executed. (2) Sample C language code and its output, as shown: #include <stdio.h>#include <conio.h>//Table …
FOR Loop in C Language: (1) The FOR statement is used to iterate over a range of values or a sequence. The FOR loop is executed for each of the items in the range. (2) Sample C language code and its output, as shown. #include <stdio.h>#include <conio.h>//Table of 2 using for loopint main(){ int x; int …
SWITCH Statement in C Language: (1) SWITCH Statement successively tests the value of an expression against a list of integer or character constants. When a match is found, the statements associated with that constant are executed. (2) Sample C language code and its output, as shown: #include <stdio.h>#include <conio.h>int main(){ int x; x = 2;switch(x) { …
If Else condition in C Language: (1) If Else statement allows us to write two alternative paths and the control condition determines which path gets executed. In an if-else statement, only the code associated with if (i.e. statement-1) or the code associated with else (i.e. statement-2) executes, never both. (2) Sample C language code and its …
Logical Operators in C Language: (1) Logical Operators are used for assigning values to variables. (2) Sample C language code and its output, as shown: #include <stdio.h>#include <conio.h>// Logical Operators in C Languageintmain(){int x;int y;x = 5; y = 7; // Returns 1printf(“Return Value: %d\n”, x > 3 && x < 10); // Returns 0printf(“Return Value: …
Comparison Operators in C Language: (1) Comparison Operators are used for comparing two variables. (2) Sample C language code and its output, as shown: #include <stdio.h>#include <conio.h>// Assignment Operators in C Languageint main(){int x;int y; x = 5; y = 5;printf(“x equals to y: %d\n”, x == y); x = 5; y = 6;printf(“x not equals …
Arithmetic Operators in C Language: (1) Arithmetic Operators are used for calculation purpose. (2) Sample C language code and its output, as shown: #include <stdio.h>#include <conio.h>// Arithmetics Operators in C Languageint main(){ int x; int y; x = 10; y = 2; printf(“Value of Addition is: %d\n”, x+y); printf(“Value of Subtraction is: %d\n”, x-y); printf(“Value of …
Variables in C Language: (1) In C language when we develop or built logic, we need variables that store information like amount, string or character. For storing this type of information, the C language provides variables like int, float, and char. (2) Sample C language code using all variables and their output, as shown: #include <stdio.h>#include …
scanf() Use in C Language: (1) scanf() is used for entering input values. (2) Sample C language code and its output, as shown: #include <stdio.h>#include <conio.h> int main(){int n;printf(“Enter the value: “);scanf(“%d”,&n);printf(“Entered value is: %d”, n);getch();return 0;} (3) After that go to the “Build” menu and select the “Build” option for publishing the code as shown. (4) …