Monday, 13 December 2021

for loop

 // why use for loop?

// for loop is used to breakdown a prt of program several times.
// it has a little different structure then do-while & whlie loop.
// besic syntex of for loop:
/*
for (size_t i = 0(expression:_1); i < count(condition:_2); i++ = i+1(expression:_3))
{
    // code to be execute //
}
*/  

/*#include <stdio.h>
int main()
{
    int num;

    printf ("enter the number which's table you want to be print: ");
    scanf ("%d", &num);

    for ( int i = 1, j=3
   
    //ex:_1 is the initialization of for loop//
    // 2. we can initialise more then one variablein for loop.
    // 3. agar variavle ki value pahle hi define ho rakhi he then
ex:_1 ki koi need nhi hoti.
    // so ex:_1 isn't not must.
    ; i < 11
   
    //ex:_2 is basically a conditional expression hota he,
    // isme basically ioop termination ki condition likhi hoti he,
    // 2. agar as ex:_2 multiple ocnditions ho then only last
condition ko true consider kiya jayega.
    /*for (size_t i = 0; i < 4(con1), j<6(con2); i++) is eg me
only con2 ko true consider kiya jayega.
    {
        //code //
     }*/
    // only last condition ko true mana jayega and baki sab ko
as it is execute kar diya jayega.
    /*for (size_t i = 0; i=4(con1),j>5(con2); i++)
    yaha only condition 2 follow hogi and con 1 as it as execute ho jayegi
    con1 ko as statement treat kiya jayega
    {
        // code //
    }
   
   
    ; i++)
    // ex:_3 is used to update(change karne ke liye)
the value of the corresponding variable.
    // 2. we can change values of more then one variable in
ex:_3 like:_i++,J++ karke.
    // 3. ex:_3 is also optioanl hota he, not must,
isko printf statement ke bad bhi likh sakte he.
    {
        printf ("%d * %d= %d\n", num,i,num*i);
        // vvvvvvvvvv. importent thing to note
        // here a imp stuff is that ki printf statement ke ander
jitne bhi  data type symbols use,
        // vo jis indentity se relate karte he ""end hone ke bad ,
lagakar ek ek karke mention kar,
        // liye ye instruct kiya jat he ki konsa symbol kis identity
ko represent karta he.

        printf ("%d",j);
    }

    // printf ("hello rishabh");
    return 0;

}*/
// project:_1(table)
#include <stdio.h>
int main()
{
    int num;
    printf ("enter the number which's table you want to print: ");
    scanf ("%d", &num);
    for (int i = 1; i < 11;)        
    {
    printf ("%d * %d= %d\n",num,i,num*i);
    i=i+1;
    }
    return 0;

}
// project_2
#include <stdio.h>
int main()
{
    int i;
    int j;
    for ( i = 0;j= 3, i < 10; i++,j++)    
    {
       printf ("%d %d\n",i,j);
    }
    return 0;
}


No comments:

Post a Comment

here we are to help you.you can watch videos and get information about :- (1) scientific facts (2) education (3) gaming (4) music (5) lyrics (6) cartoons and many more.So keep watching keep learning, thank you.

Recurtions

  //Why are recursions? //We can solve difficult long iteratively can be solved simply recursively. // there are some problems which suite...