write a c program using for loop


Q   write a name 5 time  using for loop 

  HOW T0  WORK FOR LOOP 


  1. The  initialization statement is executed only once.
  2. Then, the test expression is evaluated.If the check at expression is evaluated to false, the for loop is terminated. 
  3. However, if the take a look at expression is evaluated to true, statements within the body of for loop area unit dead, and therefore the update expression is updated.
  4. Again the test expression is evaluated.        


           This method goes on till the take a look at expression is fake.
           When the take a look at expression is fake, the loop terminates.

           To learn more about test when the test expression is evaluated to true and false), check out                 relational and logical operators.

PROGRAM


#include <stdio.h>
#include <stdlib.h>

/*
 *
 */
int main(int argc, char** argv)
{
    int i;
    for(i=1; i<=5;i++)
    {
        printf("SHASHI SHARMA\n");
    }

    return (EXIT_SUCCESS);
}


write a c program using for loop




  1. i is initialized to 1.
  2. The check expression i <=5 is evaluated.  since ONE  less and equal to FIVE than  given statements is true, the body of for loop is executed. it will print the shashi sharma on the screen .
  3. The statement i++ is executed. after the value of i will be changed in  2. Again, the check expression is evaluated so it is  true,    the cursor go to  body of for loop and executed. it will print shashi sharma second time on scree.
  4. Again, check the update statement i++ and execute i<=5,  the process goes on  again and again i <=5 .
  5. When i<=5 will be false,then for loop end .



Comments

Popular posts from this blog

Create a structure TIME with members hours, minutes and seconds. Write a C program to add two time objects by passing structure variables to function and display result in H: M: S format.

Create a structure named company which has name, address, phone and no of Employee as member variables. Read name of company, its address, phone and no of Employee. Finally display these members’ value.

Write a c program to check a voting AGE condition using if-else