While Loop
Integer
- #include<iostream.h>
- int main()
- {
- int a;
- a=1;
- while(a<=10)
- {
- cout<<"\n"<<a;
- a=a+1;
- }
- system("pause");
- return 0;
- }
- #include<iostream.h>
- int main()
- {
- int a;
- a=2;
- while(a<=20)
- {
- cout<<"\n"<<a;
- a=a+2;
- }
- system("pause");
- return 0;
- }
- #include<iostream.h>
- int main()
- {
- int a;
- a=1;
- while(a<=21)
- {
- cout<<"\n"<<a;
- a=a+2;
- }
- system("pause");
- return 0;
- }
- #include<iostream.h>
- int main()
- {
- int a;
- a=10;
- while(a>=1)
- {cout<<"\n"<<a;
- a=a–1;
- }
- system("pause");
- return 0;
- }
- #include<iostream.h>
- int main()
- {
- int a;
- a=1;
- while(a<=10)
- {
- cout<<"\n"<<a<<"sagar";
- a++;
- }
- system("pause");
- return 0;
- }
- #include<iostream.h>
- int main()
- {
- int a;
- a=1;
- while(a<=20)
- {
- cout<<"\n"<<a<<"\t"<<a*a<<"\t"<<a*a*a;
- a++;
- }
- system("pause");
- return 0;
- }
- #include<iostream.h>
- int main()
- {
- int a,b;
- cout<<"\n enter anumber=";cin>>a;
- b=1;
- while(b<=10)
- {
- cout<<"\n"<<a<<"*"<<b<<"="<<a*b;
- b++;
- }
- system("pause");
- return 0;
- }
- #include<iostream.h>
- int main()
- {
- int a,b,c;
- cout<<"\n enter anumber=";cin>>a;
- c=1;
- b=1;
- while(b<=a)
- {
- c=c*b;
- b++;
- }
- cout<<"\n factorial="<<c;
- system("pause");
- return 0;
- }