Skip to main content

WHAT IS CSS?ADVANTAGES, SYNTAX.

 CSS PROGRAMMING LANGAUGE                                                                     disadvantages CSS full form is cascade style sheets , which we call it says about how you should display the HTML elements on the screen. CSS tells us the style of the webpage let us take a simple example, if we build a home first we lay out the design that is known as the HTML language. Where the CSS means layout which means giving instructions on how the furniture should be nothing but the CSS. For example if we take PayPal we can see that the background color blue says the CSS background-color property. Netflix is also the best way of saying  CSS property, but if we remove it will be a normal webpage but with the red color and the black plus symbols it looks like the best webpage. Versions of CSS There are differen...

FLOW CONTROL STATEMENTS IN C?IF ELSE,IF ELSE LADDER ....

 FLOW CONTROL STATEMENTS:-

                                                       
control statements
statements

                              
  •  A statement that controls the order of execution of other statements of the program is known as a flow control statement.
  • Classified into two types, the first one is the selection statement which is also known as the branching statement, other one is the iteration statement is called the loop statement.

     SELECTION STATEMENTS(BRANCHING STATEMENTS):-



    • Simple if statement:-An if statement without an else statement is known as a simple if statement.
                       Syntax:-if(condition)
                                    {
                                       //statements;
                                     }
    •  Note:-Code enclosed between two flower braces is nothing but the body of the if flow control statement.
    • When the condition is true, the body of the if statement is executed and if it is false, the body of the statement is not executed.
                #include<stdio.h>  ----->header file
                void main()           ------->void main function
               {                           ------->main function definition starts
                    int a=10,b=20,c=40;------->Declaring int data type and assigning values
                    if(a>b)               --------->simple if statement giving condition to it
                   {
                        c=80;             ---------->if a<b condition is true then c=80 is printed
                       }
                     if(b<c)             ----------->if a>b is not fulfilled then b<c True a=30 is display
                   {
                         a=30;
                       }
                    printf(""%d%d%d", a,b,c);
                 }

    if else statement

    • Whenever two mutually exclusive conditions are required to be checked for selection "if-else" flow control statement is used.
              Syntax:-if(condition)
                           {
                               //statements
                            }
                           else
                           {
                              //statements
                            }
    • When the condition is true, the body of the if statement is executed condition is the false body of the else statement is executed.
                 #include<stdio.h>
                  void main()
                 {
                    int n, remainder;------#created variable n and remainder
                    printf("enter a number:")----#4
                    scanf('%d",&n);-----#storing the n value
                    remainder=n%2;------#checking n%2(4%2=0)
                    if(remainder==0)
                   {
                       printf("it is an even number");--#4 is an even number
                       }
                    else
                  {
                       printf("it is an odd number");
                       }
                 }

          if-else ladder statement:-

    • Whenever more than two mutually exclusive conditions are there, we make use of the "if-else ladder", control statements are used.
             Syntax:-if(condition)
                          {
                              //statements
                           }
                         else if(condition)
                          {
                              //statements
                           }
                         else if(conditon)
                          {
                              //statements
                           }
                         .........................
                         ........................
                          else
                          {
                              //statements
                           }
    • When the condition of the if statement is true, its body is executed and control comes out of the "if-else" ladder, if the statement is false its body is not executed.
    •  Condition of else if is verified if the condition is true its body is executed and control comes out of the "if-else" ladder condition of the "else-if" statement its body is not executed.
    • Control goes to the next "else-if" and so on. Condition is failed and the condition of all "else if failed" body of else control statements is executed.
             #include<stdio.h.>
             void main()
            { 
              int a,b,c;
              printf("enter the three sides of a triangle:");
              scanf("%d%d%d",&a,&b,&c);
              if(a==b&&b==c&&c==a)
              {
                printf("it is an equilateral triangle");
               }
              else if(a==b||b==c||c==a)
              {
                printf("isosceles triangle");
               }
              else
              {
                printf("scalene triangle");
              }

         Nested if:-

    • Placing an if statement within the body of another if statement, whenever more than one level of the condition has to be verified for selection we go for nested-if.
                                            Syntax:-if(conditon)//outer if statement
                                                         {
                                                            if(conditon)//inner if statement
                                                            {
                                                              //statements
                                                             }
                                                          }
             #include<stdio.h>
             void main()
             {
                int n;
                printf("enter a number:");
                scanf("%d",&n);
                if(n>0)
                {
                   if(n%2==0)
                   {
                     printf("it is a postive even number");
                    }
                   else
                   {
                     printf("is is a positive odd number");
                    }
               else if(n<0)
               {
                if(n%2==0)
                  {
                     printf("it is a negative even number");
                   }
                else 
                  {
                     printf("is a negative odd number");
                   }
                }
                else
                {
                   printf("it is zero");
                 }
               }

            Switch statement:-



    • Switch statement is a multi-way branching statement, many numbers of mutually exclusive conditions are to verify for selection we go for the switch flow control  statement.
    • Which allows a variable to be tested for equality against a list of values each value is called a case.
                 Syntax:-switch(expression)
                              {
                                 case value 1:statement(s)
                                                      break;
                                 case value2:statment(s)
                                                      break; 
                                 ......................................
                                 ......................................
                                 default:statement(s)
                              }
    • The expression is evaluated once and compared with the value of each case, if there is a match, the corresponding statements after the matching case are executed until the break is encountered.
    •  Default statements are executed, do not use the break,all statements after the matching "case" are executed the default clause inside the switch is optional.
              #include<stdio.h>
              void main()
              {
                int n;
                printf("enter the digit:");
                scanf("%d",&n);
                swithc(n)
                {
                  case 0:printf("zero");
                             break;
                  case 1:printf("one");
                             break;
                  case 2:printf("two");
                            break;
                  case3:printf("three");
                            break;
                 case4:printf("four");
                            break;
                 default:printf("invalid input,please enter only a digit");
                };
            }

         ITERATION STATEMENTS 

    for loop and while loop
    for loop do while


    • For Statements:-Is one of the three iteration statements in C, whenever any code is required to be executed repeatedly we use it for statement.
                Syntax:-for(initialization;condition;updation)
                             {
                                 //body
                              }
    • For loop has four things loop counter initialization, condition, body, and loop counter updation(incrementation/decrementation).
    • Loop counter initialization happens only once if the condition is true body is executed after executing the body, the loop counter is updated, After loop counter updation, the condition is verified.
    • Condition is true,body is executed and so on, if it is false, controls come out of the loop that is the loop is exhibited.
              #include<stdio.h>
              void main()
              {
                  int i;//loop counter
                  for(i=1;i<=10;i++)-->i=1(intialization),i<=10(condition),i++(incrementation)
                  {
                     printf("%d\n",i);
                   }
               } 

      WHILE STATEMENT

    • While the statement is one of the 3 iteration statements in c, whenever some code is required to be executed repeatedly we go for a while loop.
                 SYNTAX:- while(condition)
                                    {
                                        //statements
                                       //loop counter updation
                                     }
    • Loop counter is initialized, and the first condition is verified if the condition is false loop is exited condition is true body is executed and the loop counter is updated again verified, and so on.
             #include<stdio.h>
             void main()
             {
                int i=0;//loop counter initalization)
                while(i<=10)
                {
                   printf("%d\n",i);
                   i++;//loop counter incrementation
                 }
               }

     DO WHILE STATEMENT:-

    • Do while statement is one of the iterations statements in c whenever some code is required to be executed repeatedly we go for the do-while loop, which is an exit condition checking loop. 
               Syntax:-do
                             {
                                //statements
                               //loop counter updation
                             }while(condition);
    • Loop counter is initialized first, the body is executed, the loop counter is updated condition is verified if the condition is false,  a loop is exited if the condition is true, and the body is executed.
             #include<stdio.h>
            void main(0
            {
                int i=1;//loop counter initialization
                do
                {
                   printf("%d\n",i);
                   i++;//loop counter incrementaion
                }while(i<=10)
            }
    • In this blog we learned about flow control statements in simple if, if else,if-else ladder, for loop, while, and do-while, in the next blogs we are going to learn about arrays and their types.
    • There are different operators in C arithmetic operator, relational, assignment,t, and so on...








    Comments

    Post a Comment

    Popular posts from this blog

    BASIC PROGRAM IN C LANGUAGE? INCLUDE, HEADER.

    SIMPLE PROGRAM TO PRINT NAMES ON                     CONSOLE USING C LANGUAGE #include <stdio.h> which means that <stdio.h> is the header file that says, that standard input and output header file, so every time there is a format writing the c language program that is the starting line of the code. And Include is the command that we use in the program to include the header file <stdio.h> and this file contains the Printf function means to, display any text onto the console. To use the print function, we need to use #include<stdio.h> then only the print function can be accessed otherwise not.   The first line of the code of the program is, #include<stdio.h> this is the most compulsory step we can say in a c program.                                                    ...

    ARRAYS IN C?SCALAR VARIABLE,DISADVANTAGES

    SCALAR VARIABLE:-                                                       A  scalar variable is that which can hold only one value it is known as a scalar variable. For eg:- int a=10;                          a=30; DISADVANTAGES OF SCALAR VARIABLE :-      Whenever multiple data items are required to be in the computer memory and access those data items scalar variables have 2 limitations: increase code and performance problems. AGGREGATE VARIABLE:- A variable that can hold multiple values(data items) is known as an aggregate variable. WHAT IS AN ARRAY :- An array is an index-based collection of homogenous elements, the array is a collection of  (continuous) memory locations referred to by a common name that can hold multiple values. Is a subscripted variable that can...

    WHAT IS C LANGUAGE? USES, COMPILER

    C LANGUAGE C language compiler, C is one of the most popular languages in programming,  Dennis M.RITCHIE invented C programming in the year the 1970s,  C is a high-level programming language which means, its instructions are away from the understanding of the processor. There is a small difference between C language and C++ that is c does not provide object-oriented support. C++ gives class-based support(ORS) which means the same as the previous line in this blog. WHY LEARN C  LANGAUGE Learning C language and a compiler will be useful for coding. Especially for making a website with C language. If we learn C++ it will be useful for making a website. This means C language is only used for making a website but C++ is used for adding colors background colors etc. C language is one of the straightforward languages means easily understandable language. USES OF C LANGUAGE While the C language is used, in the creation of hardware devices.  It is also used in the OS, that ...