Monday, 13 December 2021

do-while loop

 // do whlie loop at ek bar to execute hota hi he.

// ek bar execute hone ke bad ye condition tak execute hota hi rahega,
// and condition flase hone par he loop se exit ho jayega.
// besic syntex of do while loop
/* do{
    /code to be executed./
} while (condition)
eg.
{
    int i=0;
do
{
    i=i+1;
    printf ("%d", i);
} whlie (i<10)
return 0;
}*/

#include <stdio.h>
int main()
{
    int num;
    int index=0;
    printf ("enter the number:\n");
    scanf ("%d",&num);

    do{
        printf ("%d\n", index+1);
        index= index+1;

    } while(index<num);

    return 0;

}
// project:_2
/*#include <stdio.h>
int main()
{
    int num;
    int sum=0;
    do
    {
        printf ("enter the number: ");
        scanf ("%d",&num);
        sum +=num;

    } while (num != 0);
    printf ("the sum is= %d", sum);

    return 0;
   
}*/
/*#include <stdio.h>
int main()
{
    int n, sum = 0;
    do
    {  
printf("Enter a number: ");
scanf("%i", &n);
        sum += n;
    }
    while(n != 0);
    printf("Sum is = %d",sum);

    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...