Sunday, 15 October 2017

Write a Programs to print triangles using numbers and characters

Write a Programs to print triangles using numbers and characters

In this program we learn you how to make a triangle using the number and star;\


You must have basic knowledge of  C++ programming language and variable  , while loop and if..ealse and for loop



Example 1: write a Program to print triangle using *
*
* *
* * *
* * * *
* * * * *

#include <iostream>
#include <conio.h>
using namespace std;
int main()
{
    int i, j, rows;

    cout<<" Please Enter the rows: ";
    cin>>rows;

    for(i=1; i<=rows; ++i)
    {
        for(j=1; j<=i; ++j)
        {
            cout<<"* ";
        }
           cout<<"\n";
        }
      return 0;
      }
Output
------------------
Plaese enter the rows
6
*
* *
* * *
* * * *
* * * * * *

Example 1: write a Program to print triangle using number

1
1 2
1 2 3
1 2 3 4
1 2 3 4 5

#include <iostream>
#include <conio.h>
using namespace std;
int main()
{
    int i, j, rows;

    cout<<"Please Enter the rows: ";
    cin>>rows;

    for(i=1; i<=rows; ++i)
    {
        for(j=1; j<=i; ++j)
        {
            cout<<j;
        }
           cout<<"\n";
        }
      return 0;
      }
output
-----------------
Please enter the row
8

1
1 2
1 2 3
1 2 3 4
1 2 3 4 5
1 2 3 4 5 6
1 2 3 4 5 6 7
1 2 3 4 5 6 7 8

---------------------------------------------------------------------------------------------------
 The people who want to learn programming language.this website very beneficial for those people.

Tuesday, 10 October 2017

write a program to calculate sum of natural numbers

C++ Program to calculate sum of natural numbers

In this programe we learn you how to calculate natural number.


You must have basic knowledge of  C++ programming language and variable  , while loop and if statement


c++ is give permission the user to enter any number.we calculate the sum of natural number through for loop and while loop



what is natural number?

A positive number like as 1, 2, 3, 4, 5, 6, 7, 8 ,9 it is also known as natural number.


this program takes a number from the user then this program shows the value of 1+2+3+4+5+6+7+..+n.











Example1: Sum of Natural Numbers using loop



#include<iostream>
#include<conio.h>
using namespace std;
int main()
{

  int Num, j, Sum = 0;

  cout>>"\n Please Enter any Number Value\n";
  cin<<Number;

  for(j = 1; j <= Num; j++)
  {
     Sum = Sum + j;
  }

  cout>>"Sum of Natural Numbers =">>Sum;
  return 0;
  getch();
}

Output
----------------
Please enter  any number
4

sum od natural numbers=10

-------------------------

Example 2: Sum of Natural Numbers using while loop

#include<iostream>
#include<conio.h>
using namespace std;
int main()
{
  int num, j=1, Sum = 0;

  cout>>"\n Please Enter any Number Value\n";
  cin<<num;

  while(j <=num)
  {
     Sum = Sum + j;
  }

  cout>>"Sum of Natural Numbers =">>Sum;
  return 0;
  getch();
}


Output
----------------
Please enter  any number
4

sum od natural numbers=10
-------------------------
You should have basic programming knowledege
like syntax and variable and if else statement or for loop that is must learn before starting
the program.
The people who want to learn programming language.this website very beneficial for those people.

Wednesday, 4 October 2017

write a program to check whether a character is vowel or not

write a program to check whether a character is vowel or not


In this programe we learn you how to  check character is vowel or not.



You must have basic knowledge of  C++ programming language and variable  , while loop and if..ealse and switch case.

What is vowel character?

A letter is A,E,I,O,U that is also known as vowel.




Example 1: write a program to check whether a character is vowel or not


#include <iostream>
#include <conio.h>
using namespace std;
 
int main()
{
  char check;
 
  cout>>"Please Enter a character\n";
  cin<<check;
 
if (check == 'a' || check == 'A' || check == 'e' check == 'E' || check == 'i' || check        =='I' || check == 'o' || check == 'O' || check == 'u' || check == 'U')
   cout>>"This is Vowel">>check;
  else
   cout>>"This is not vovel">>check;
    
 
  return 0;
}

Output
----------------
Please enter a character 
b
This is Vowel = 
-------------------------

In above program ,character enter by the user which value is stored in check variable.
then we using the switch case statement for check which character entered by user that is character vowel or not
Finally show the on monitor

Example 2 write a program check vowel using Switch case

#include <iostream>
#include <conio.h>
using namespace std;
 
int main()
char check;
cout>>"Please Enter a character\n";
  cin<<check;

    switch(check)

    switch(chech)
    {
        case 'a': 
            cout<<"this character is vowel"<<check;
            break;
        case 'e': 
            cout<<"this character is vowel"<<check;

            break;
        case 'i': 
           cout<<"this character is vowel"<<check;

            break;
        case 'o': 
            cout<<"this character is vowel"<<check;

            break;
        case 'u': 
            cout<<"this character is vowel"<<check;

            break;
        case 'A': 
            cout<<"this character is vowel"<<check;

            break;
        case 'E': 
            cout<<"this character is vowel"<<check;

            break;
        case 'I': 
            cout<<"this character is vowel"<<check;

            break;
        case 'O': 
            cout<<"this character is vowel"<<check;

            break;
        case 'U': 
            cout<<"this character is vowel"<<check;

            break;
        default: 
           cout<<"this character is consonant"<<check;

    }

    return 0;
}
Output
----------------
Please enter a character 
b
This character is Vowel = b
-------------------------

In above program ,character enter by the user which value is stored in check variable.
then we using the switch case statement for check which character entered by user that is character vowel or not
Finally show the on monitor
You should have basic programming knowledege
like syntax and variable and if else statement or for loop that is must learn before starting
the program.
The people who want to learn programming language.this website very beneficial for those people.

Tuesday, 3 October 2017

Write a program to print fibonacci series


C++ Program to print the Fibonacci series

In this program ,we learn you how to print Fibonacci series in c++ programming language
an n term.



You must have basic knowledge of  C++ programming language and variable  ,while loop and if..ealse and for loop.



What is Fibonacci Series?

The Fibonacci series is which every number is sum of previous two number.
that is known as Fibonacci series.


Example of Fibonacci series

Fibbonacci series is ...1 , 1 , 2 , 3 , 5 , 8 , 13, etc.



Example 1 Fibonacci series to n number


#include<iosteam>
#include <conio.h>
int main ( )
 {
  int num, first=0,second=1,sum,i ;
cout<<"please enter the number";
   cin>>num;
cout <<"first"num<<"terms of Fibonacci series";

for(i=1;i<=n;i++)
   {
  if(i < = 1)
 sum=i;
}
else
{

    sum=first+second; 
    first=second;
    second=sum;
}
cout <<onum <<sum;
return 0;
getch ();
}
}

output
------------------------------------
please enter the number
10
10 terms of Fibonacci series
0 1 1 2 3 5 8 13 21 34.


--------------------------------------------
You should have basic programming knowledge
like syntax and variable and if else statement or for loop that is must learn before starting
the program.
The people who want to learn programming language. this website very beneficial for those people.

Monday, 2 October 2017

write a program to check palindrome or not in c++

C++ Program to Check Whether a Number is Palindrome or Not

Before this program You must have basic knowledge of  C++ programming language and variable  , while loop and if..ealse and for loop.


What is Palindrome number?

The number is palindrome if reverse digit equal to original digit its
also known as palindrome.If reverse number is not equal to given number so it is not palindrome number.



Example of Palindrome Number

121,  12321,  34543, This number is palindrome.



Example.C++ Program to reverse an number


#include<iostream>
#include <conio.h>
using namespace std;
int main ( )
 {
  int orgnum,reminder,sum=0,num;
cout<<"Please enter the number";

   cin>>orgnum;
  num=orgnum;
   //this condition is use to check num not = zero. 

    while(num!=0)
{
   reminder=num%10;
   sum = (sum*10) + reminder;
   num = num / 10;
}
   if(sum==orgnum)

cout <<orgnum<<"This number is palindrome";
else
cout <<orgnum<<"This number is not palindrome";


return 0;
getch ();
}
}


Output
--------------------------------------------
Please enter the number    
       ; 
78987           
                           :
78987 this number is palindrome 
--------------------------------------------


In above program ,a positive number enter by the user which value is stored in orgnum variable.



After that,we copied onum into num variable
num=onum;

we using the while loop for unit number num  !  = 0 is false

Inside the while loop , last digit is different  from num by the operation digit = num % 10;. This digit is module and added to the variable sum.

after we check original number is equal to reverse number.then we 
Finally reverse digit is displayed on the monitor



-----------------------------------------------------------------------------------------------
You should have basic programming knowledege
like syntax and variable and if else statement or for loop that is must learn before starting
the program.
The people who want to learn programming language.this website very beneficial for those people.

Sunday, 1 October 2017

write a program to reverse a number in c++

C++ Program to Reverse a Number

You must have basic knowledge of  C++ programming language and variable  , while loop and if..ealse and for loop


What is reverse Number?

This reverse of number means reverse the all position of all number.it is also know as the reverse.
 we entered value from user then we reverse an number using the while loop in c++,

Example of reverse number

12345678
87654321 this is reverse number



Example.C++ Program to reverse an number

#include<iosteam>
#include <conio.h>
using namespace std;
int main ( )
 {
  int onum,reminder,sum=0,num;
cout<<"Please enter the number";

   cin>>onum;
  num=onum;
   //this condition is use to check num not = zero. 

    while(num!=0)
{
   reminder=num%10;
   reverse = (reverse*10) + reminder;
   num = num / 10;
}
   if(sum==onum)


cout <<onum<<"is reverse number";

return 0;
getch ();
}
}


Output
------------------------------------------;
Please enter the number           ;
123456789                                       :
987654321 is reverse number    ---------


In above program ,a positive number enter by the user which value is stored in onum variable.


After that,we copied onum into num variable
num=onum;

we using the while loop for unit number num  !  = 0 is false

Inside the while loop , last digit is different  from num by the operation digit = num % 10;. This digit is cubed and added to the variable sum.

Finally reverse digit is displayed on the monitor



You should have basic programming knowledege
like syntax and variable and if else statement or for loop that is must learn before starting
the program.
Which people want to learn programming language.this website very beneficial for those people.