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 different versions available now in case it is developed by Wium we have three versions that are css1, css2, and css3. Currently we are using this css3 version this is the best version fo

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

    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 is the operating sy

    OPERATORS IN C?ARITHMETIC, ASSIGNMENT....

      O PERATORS IN C                                                                  operators A n op erator is a symbol that acts on data items known as operands in order to process them.   for eg-   a+b   ( "a" and "b" are operands, and "+" is an operator ).               c-a     ( " c "&"a"  both are operands "-" operator ).    We can do addition, subtraction, multiplication, division, etc........ Operand and the operator plays a very important role in the programming language. CLASSIFICATION OF OPERATORS B ased number of operands operating upon, operators are classified into three types. Unary operators(operate upon single operand). Binary operators(operate upon two operands). Ternary operators(three operands). On the type of execution they perform on the operands, operators are classed  into six types Arithmetic operator :-arithmetic operators are the operators which perform addition( + ), subtraction( - ), multipli

    FUNCTIONS IN C?CLASSIFICATION, PARAMETERS, LOCAL VARIABLE.

     WHAT IS A FUNCTION                                                                         function A self-contained, named block of code that performs the specific task when called is nothing but a function. Note:-functions are the task performers in C projects.  FUNCTIONS CLASSIFICATION We have 2 types of functions they are user-defined functions and library functions. A pre-created function that comes with C installation is nothing but a library function, For eg:- print () and scanf(). Library functions are ready-made named code blocks. We need not create them, Just use them in our programs. We can make use of this library function by making the library function available to the program and the next step is calling the library function. Our own created function which is the program-created function is nothing but a user-defined function , eg- the main function is the example of a user-defined function. BENEFITS OF USER-DEFINED FUNCTION There are many benefits of user-defined func