while Loop
C Language में दूसरा loop, while loop है । while loop को Entry Controlled कहते है । Entry Controlled का मतलब है कि इनमें पहले condition check होती है और बाद statement(s) execute होते है।
Syntax :
Program to print numbers from 1 to 10 using while loop
1 2 3 4 5 6 7 8 9 10
Output :
Program to print numbers from 1 to 10 using while loop
10 9 8 7 6 5 4 3 2 1
Output :
C Language में दूसरा loop, while loop है । while loop को Entry Controlled कहते है । Entry Controlled का मतलब है कि इनमें पहले condition check होती है और बाद statement(s) execute होते है।
Syntax :
Program to print numbers from 1 to 10 using while loop
1 2 3 4 5 6 7 8 9 10
#include<stdio.h>
#include<conio.h>
int main(void)
{
int i;
clrscr();
printf("Numbers from 1 to 10\n");
i=1;
while(i<=10)
{
printf("%d ", i);
i++;
}
getch();
return 0;
}
int main(void)
{
int i;
clrscr();
printf("Numbers from 1 to 10\n");
i=1;
while(i<=10)
{
printf("%d ", i);
i++;
}
getch();
return 0;
}
1 2 3 4 5 6 7 8 9 10
Program to print numbers from 1 to 10 using while loop
10 9 8 7 6 5 4 3 2 1
#include<stdio.h>
#include<conio.h>
int main(void)
{
int i;
clrscr();
printf("Numbers from 10 to 1\n");
i=10;
while(i>=1)
{
printf("%d ", i);
i--;
}
getch();
return 0;
}
int main(void)
{
int i;
clrscr();
printf("Numbers from 10 to 1\n");
i=10;
while(i>=1)
{
printf("%d ", i);
i--;
}
getch();
return 0;
}
10 9 8 7 6 5 4 3 2 1
No comments:
Post a Comment