Saturday, 23 June 2012

how to find the factorial of a number using while loop in c++


how to find a factorial of a number in c++
How to find a factorial of a number in c++:- Here is the source code to find the factorial of a number using while loop in c++.It is quite simple including the body.So try it and give your feed back to me.
#include<iostream.h>
#include<conio.h>
main()
{
      int x;
      cout<<"enter the value for which you want the factorial:";
      cin>>x;
      int f=1;
      int n=1;
      while(n<=x)
      {
                 f=f*n;
                 n=n+1;
                 }
                 cout<<"this is the required value:"<<f<<endl;
                 getch();
                 }
End

how to make your desired table using while loop in c++


how to make a table using c++

How to make a table in c++:-
I also tell you about write the table using c++ before,But now i tell you a different method to write your desired table in c++ using while loop in c++. So try this it is very simple to learn.

#include<iostream.h>
#include<conio.h>
main()
{
      int x,y,z;
      y=1;
      cout<<"enter the value for which you want the table:";
      cin>>x;
       cout<<"enter the value up to  which you want the table:";
       cin>>z;
      while(y<=z)
      {
                  cout<<x<<"*"<<y<<"="<<y*x<<endl;
                  y=y+1;
                  }
                  getch();
                  }
End

A program in c++ that determine the character is vowel or consonant



This is the source code to determine "is the entered character is vowel or consonant?" 
#include<iostream.h>
#include<conio.h>
main()
{
      char ch;
      cout<<"Enter an alphabet:";
      cin>>ch;
      if(ch=='a'||ch=='A'||
                          ch=='e'||ch=='E'||
                          ch=='i'||ch=='I'||
                          ch=='o'||ch=='O'||
                          ch=='u'||ch=='U')
                          cout<<"it is a vowel";
                          else
                          cout<<"it is a consonant";
                          getch();
                          }
End