Programming Shortcut

Write, Run and execute Your programs with simple and esay way by Programming Shortcut

Monday, February 4, 2019

program to check a alphabet is vowel or consonant in c++

Hello Friends! Welcome to programming shortcut
Today will discuss:
--> Program to find whether the alphabet is a vowel or consonant  in c++ or
--> c++ program to check vowel or consonant using a switch or
--> program to check an alphabet is a vowel or consonant in c++


#include
using namespace std;
int main(){
 char ch;
 cout  cin>>ch;
 switch(ch)
 {
  case 'a':
  case 'e':
  case 'i':
  case 'o':
  case 'u':
  case 'A':
  case 'E':
  case 'I':
  case 'O':
  case 'U':
   cout    break;
  default:
   cout  }
 return 0;
}



Output:

   First, run:
   Enter the alphabet :
   a
   The alphabet is a vowel

   Second-time run:
   Enter the alphabet :
   d
   The alphabet is a consonant

Explanation: In this programming, we use the Switch case to check an alphabet is a vowel or consonant


Hello, Friend We first write the program and compile them and run the program to check compiler error or run time error.
Please share the site and comment on your ideas and your suggestions. All suggestion was all welcome.
If any question or doubt in the programming please mention the comment.
Thank yours very much. 
More Code »

Program to find whether the alphabet is a vowel or consonant

Hello Friends! Welcome to programming shortcut
Today will discuss:
--> Program to find whether the alphabet is a vowel or consonant or
--> c program to check vowel or consonant using a switch or
--> program to check an alphabet is a vowel or consonant


#include
#include
void main()
{
char ch;
printf("Enter an alphabet : \n");
scanf("%c",&ch);
switch(ch)
{
case 'a':
case 'e':
case 'i':
case 'o':
case 'u':
 case 'A':
case 'E':
case 'I':
case 'O':
case 'U':
printf("Alphabet is a vowel\n");
break;
default:
printf("Alphabet is a consonant\n");
}
getch();
}


Output:

   First, run:
   Enter the alphabet :
   a
   Alphabet is a vowel

   Second Time run:
   Enter the alphabet :
   d
   Alphabet is a consonant

Explanation: In this programming, we use the Switch case to check an alphabet is a vowel or consonant


Hello, Friend We first write the program and compile them and run the program to check compiler error or run time error.
Please share the site and comment on your ideas and your suggestions. All suggestion was all welcome.
If any question or doubt in the programming please mention the comment.
Thank yours very much. 
More Code »

Short name by java program

Hello Friends, Welcome to my blog

Today will write a program to the short name by java program, this problem is also asking in many ways they are following:
 1. Java Program to Convert a Person Name in Abbreviated.
 2. wap to print the short name of the user.
 3. Java program to convert full name to short name.
 4. Java program to a short name.
 5. Abbreviation of Java programming language.

 Problem:-
    Enter Name: Anant Deep Vishwakarma
        Output: A. D. Vishwakarma

 Solutions:-
    1. Store Name in a name String.
    2. Split Name String and Store to a temp string array.
    3. Find temp string array length store value in other variables.
    4. Take a loop to store all value to expect the last name and print the first character by value with
       dot or abbreviation.
    5. then print the last value of temp string all Character

 Explain:
    For example a store name 'Anant Deep Vishwakarma'in a name string and then split value into temp string array as temp[0]='Anant', temp[1]='Deep' and temp[2]='Vishwakarma', after that count length of temp string array and use loop to left the last index value last name 'Vishwakarma', in loop print first char of every index value within loop. in the last print last index of program

Best java program example:

    import java.util.*;
    class SName
    {
     public static void main(String[] args)
        {
            String n;
            Scanner c=new Scanner(System.in);
            System.out.print("Enter the user name:");
            n=c.nextLine();
            String [] t=n.split(" ");
            int l=t.length;
            System.out.print("Your Short name:");
            for(int i=0;i             {
                System.out.print(t[i].charAt(0)+".");
            }
            System.out.print(t[l-1]);
         }
    }
     
I hope you understand the program is any query please comment below your query I reply your questions soon.
Bye..
       
More Code »

Java program to perform sum of digits until single digit is obtained

 Hello Friends!
 Today will discuss do while loop with an example, how to make a program in java by do-while loop, do while loop in java program an example with explanation.
 Write a program in java to find the sum of digits of a number until the sum is reduced to 1 digit.
 For example:
  The number is 538769.
  Then 5+3+8+7+6+9=38
  3+8=11
   11=2

Finding sum of digits of a number until sum becomes single digit java program


import java.util.Scanner;
public class do_while {
   public static void main(String[] args){
    long num,dig,sum;
    Scanner in =new Scanner(System.in);
System.out.print("Enter a number :");
    num=in.nextLong();
    System.out.println("");
System.out.print(num);
do{
        sum = 0;
        while(num!=0)
{
dig=num%10;
            sum+=dig;
            num/=10;
}
        System.out.print("->"+sum);
        num=sum;
}while(num/10!=0);
   }
}
Output: Enter a number : 538769
        538769->38->11->2

Explanation :

    do{
/* 1: program code */
}while(num/10!=0);
        The Above Condition is not exited while a number is more than one digit.
     
/* 1: program code */
while(num!=0)
{
dig=num%10;
sum+=dig;
num/=10;
}
     Here we use program code to find a sum of digit then the given program exapmle is for "Sum of digits of a number until the sum is reduced to 1 digit"

So we find Your Program

I make this programming and hope you are like the post if are you like the post you can please comment and Share the post to reach more people.
If any doubt about this java programming code or input & output please comment below
If you have another question about java programming send an email by contacting us form are given on the page right side.
I am Try to Help in your Programming Language by Programming Shortcut

Please share your experience about this post,
Thank You!
More Code »

Sum of digits of a number until the sum is reduced to 1 digit in c++

 Hello Friends! Welcome to Programming Shortcut
Today will discuss do while loop with an example, how to make a program in c++ by the do-while loop, do while loop in c++ with an example with explanation.
 Write a program in c++ to find the sum of digits of a number until the sum is reduced to 1 digit.
 For example
  The number is 538769.
  Then 5+3+8+7+6+9=38
            3+8=11
            11=2

Sum of digits of a number until the sum is reduced to 1 digit in c++ program

#include
using namespace std;
int main()
{
long num,dig,sum;
cout cin>>num;
cout do{
sum = 0;
while(num!=0)
{
dig=num%10;
sum+=dig;
num/=10;
}
cout" num=sum;
}while(num/10!=0);  /*while num is more than one digit*/
return 0;
}

Output: Enter The number 538769
            538769->38->11->2

Explanation :

      do{
/* 1: program code */
}while(num/10!=0);

                The Above Condition is not exit while num. is more than one digit.
     
/* 1: program code */
while(num!=0) 
{
dig=num%10;
sum+=dig;
num/=10;
}

     Here we use program code to find a sum of digit then the given program example is for "Sum of digits of a number until the sum is reduced to 1 digit"

So we find Your Program what we want. 

I make this programming and hope you are like the post if are you like the post you can please comment and Share the post to reach more people.
If any doubt about this c programming code or input & output please comment below
If you have another question about c programming send an email by contacting us form are given on the page right side.
I am Try to Help in your Programming Language by Programming Shortcut

Please share your experience about this post,
Thank You!
More Code »

Sum of digits of a number until the sum is reduced to 1 digit in c

 Hello Friends!
 Today will discuss do while loop with the example, how to make a program in c by a do-while loop,   do while loop in c programming example with explanation and how to make c program to Sum of digits of a number until the sum is reduced to 1 digit. Nested Loop in c program
 Write a program in c to find the sum of digits of a number until the sum is reduced to 1 digit.
 For example: 
 The number is 538769.
 Then 5+3+8+7+6+9=38
          3+8=11
          11=2

Sum of digits of a number until the sum is reduced to 1 digit in c program

#include
int main(void)
{
long num,dig,sum;
printf("Enter a number : ");
scanf("%ld",&num);
printf("\n%ld",num);
do{
sum = 0;
while(num!=0)
{
dig=num%10;
sum+=dig;
num/=10;
}
printf("->%d",sum);
num=sum;
}while(num/10!=0);  /*while num is more than one digit*/
return 0;
}

Output: Enter The number 538769
              538769->38->11->2


Explanation :

      do{
/* 1: program code */
}while(num/10!=0);
The Above Condition is not exit while num. is more than one digit.
      
 /* 1: program code */
while(num!=0) 
{
dig=num%10;
sum+=dig;
num/=10;
}
Here we use program code to find a sum of digit then the given program example is for "Sum of digits of a number until the sum is reduced to 1 digit"

So we find Your Program what we want. 

I make this programming and hope you are like the post if are you like the post you can please comment and Share the post to reach more people.
If any doubt about this c programming code or input & output please comment below
If you have another question about c programming send an email by contacting us form are given on the page right side.
I am Try to Help in your Programming Language by Programming Shortcut

Please share your experience about this post,
Thank You!
More Code »

Java program to reverse a number


Hello friends! welcome to my blog
Today will discuss the basic concept and simplest way to how to reverse a number in java by programming and how to make program for reverse of a number without array in java programming. How to how to count number of digit in a number in java programming, write a program to count number of digit in java

Write a program to reverse a number


import java.util.Scanner;
public class reverse{
public static void main(String[] args){
int n, r=0,d;
    Scanner in =new Scanner(System.in);
    System.out.println("Enter the number");
n=in.nextInt();
System.out.println("Number befour reverse= " +n);
while(n>0){
d= n%10;
r= r*10+d;
n=n/10;
}
System.out.println("Number After reverse= "+r);
}
}


Output: Enter the Number
        1234
Number befour reverse= 1234
Number After reverse= 4321

Write a program to count no of digit of a number


import java.util.Scanner;
public class count{
public static void main(String[] args){
int n, c=0,d;
    Scanner in=new Scanner(System.in);
    System.out.println("Enter the number");
n=in.nextInt();
while(n>0){
d= n%10;
n=n/10;
c++;
}
System.out.println("The entered number has "+ d +"digit");
}
}


Output: Enter the Number
            1234
   The entered number has 4 digit

 

I make this programming and hope you are like the post if are you like the post you can please comment and Share the post to reach more people.
If any doubt about this java programming code or input & output please comment below
If you have another question about java programming send an email by contacting us form are given on the page right side.
I am Try to Help in your Programming Language by Programming Shortcut

Please share your experience about this post,
Thank You!
More Code »

How to reverse a number in c++ program

Hello friends! welcome to my blog
Today will discuss the basic concept and simplest way to how to reverse a number in c++ by programming and how to make program for reverse of a number without array in c++ programming. How to how to count number of digit in a number in c++ programming.

write a program to reverse a number



#include
using namespace std;
int main()
{
    int n, r=0,d;
    cout cin>>n;
cout while(n>0){
d= n%10;
r= r*10+d;
n=n/10;
}
cout return 0;
}


Output: Enter the Number
             1234
     Number befour reverse= 1234
     Number After reverse= 4321

program to count no of digit of a number

#include
using namespace std;
int main()
{
int n, c=0,d;
    clrscr();
    cout cin>>n;
while(n>0){
d= n%10;
n=n/10;
c++;
}
cout return 0;
}


Output:Enter the Number
            1234
    The enter number have 4 digit
 


I make this programming and hope you are like the post if are you like the post you can please comment and Share the post to reach more people.
If any doubt about this c++ programming code or input & output please comment below
If you have another question about c++ programming send an email by contacting us form are given on the page right side.
I am Try to Help in your Programming Language by Programming Shortcut

Please share your experience about this post,
Thank You!
More Code »

reverse a number in c program

Hello friends! welcome to my blog
Today will discuss the basic concept and simplest way to how to reverse a number in c by programming and how to make program for reverse of a number without array in c programming,

Write a program to reverse a number


#include
int main(void)
{
int n, r=0,d;
    clrscr();
    printf("Enter the number\n");
scanf("%d",&n);
printf("Number befour reverse= %d ",n);
while(n>0){
d= n%10;
r= r*10+d;
n=n/10;
}
printf("Number After reverse= %d", r);
return 0;
}


Output: Enter the Number
        1234
Number befour reverse= 1234
Number After reverse= 4321

Program to count no of digit to a number


#include
int main(void)
{
int n, c=0,d;
    clrscr();
    printf("Enter the number\n");
scanf("%d",&n);
while(n>0){
d= n%10;
n=n/10;
c++;
}
printf("The entered number has %d digits", c);
return 0;
}


Output: Enter the Number
       1234
   The entered number has 4 digits

I make this programming and hope you are like the post if are you like the post you can please comment and Share the post to reach more people.
If any doubt about this c programming code or input & output please comment below
If you have another question about c programming send an email by contacting us form are given on the page right side.
I am Try to Help in your Programming Language by Programming Shortcut

Please share your experience about this post,
Thank You!
More Code »

sum and product of digit program in java

Hello Friends! Welcome to my blog
Today We will Discus about how to calculate sum of digit and product of digit using while loop of a number in java programming language
The sum of digit of a number is added every digit of number
For example
a number is 8554 then sum of digit is 8+5+5+4=22
And product of digit of a number is multiplication of each digit
For Example
a number is 4581 then product of digit is 4*5*8*1=160
See programming Example:


java program find to sum of digits




import java.util.Scanner;
public class sum_of_digit {
public static void main(String[] args) {
int n, d, s = 0;
Scanner in = new Scanner(System.in);
System.out.println("enter the number");
n = in.nextInt();

while (n > 0) {
d = n % 10;
s = s + d;
n = n / 10;
}
System.out.println("The sum of digit 458"+s);
}
}


Output:
enter the number
8554
The sum of digit 22


java program to find product of digits



import java.util.Scanner;
public class product_of_digit {
public static void main(String[] args) {
int n, d, p = 1;
Scanner in = new Scanner(System.in);
System.out.println("enter the number");
n = in.nextInt();

while (n > 0) {
d = n % 10;
p = p * d;
n = n / 10;
}
System.out.println("The product of digit "+ p);
}
}


Output:
enter the number
4581
The product of digit 160

I make this programming and hope you are like the post if are you like the post you can please comment and Share the post to reach more people.
If any doubt about this java programming code or input & output please comment below
If you have another question about java programming send an email by contacting us form are given on the page right side.
I am Try to Help in your Programming Language by Programming Shortcut
Please any query email programmingshortcut@gmail.com

Please comment your experience on this post,
Thank You!

More Code »

sum of digits and product of digits program in cpp

Hello Friends! Welcome to my blog
Today We will Discus about how to calculate sum of digit and product of digit using while loop of a number of c++ programming language
The sum of digit of a number is added every digit of number
For example
a number is 5392 then sum of digit is 5+3+9+2=19
And product of digit of a number is multiplication of each digit
For Example
a number is 5392 then product of digit is 5*3*9*2=270
See programming Example:

c++ program find to sum of digits



      #include
      using namespace std;
 int main(){
            int n ,d,sum=0;
            cout             cin>>n;
            while(n>0){
                d=n%10;
                sum=sum+d;
                n=n/10;
           }
      cout return 0;
     }


Output:
enter The number
185755
The sum of digit= 31


C++ program to find product of digits


    #include
    using namespace std;
    int main(){
       int n ,d,pro=1;
       cout        cin>>n;
       while(n>0){
          d=n%10;
          pro=pro*d;
          n=n/10;
        }
        cout return 0;
    }

Output:
enter The number
5846
The product of digit= 960


I make this programming and hope you are like the post if are you like the post you can please comment and Share the post to reach more people.
If any doubt about this c++ programming code or input & output please comment below
If you have another question about c++ programming send an email by contacting us form is given on the page right side.
I am Try to Help in your Programming Language by Programming Shortcut
Please any query email programmingshortcut@gmail.com

Please comment your experience on this post,
Thank You!

More Code »
Newer Posts Older Posts Home

About Programming Shortcut

This is a programming learning website that can help you learn and when your write your programming code. And all programming code is compiled run programming code in the following programming language C, c++, Java, php and Javascript Languages. find your programming read, understand the programming then copy and past and run your program and save your golden time to typing the program becuse you learn more in leas time. All Programming is codeing is ease to understand the programming