Programming Shortcut

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

Tuesday, February 6, 2018

Switch case in program cpp example

Hello friends! Welcome to my blog

Today we discuss How to use switch case conditional statement in c++ and how to program switch case in c++ programming examples

What is switch Case?

Switch case is a multi-way conditional statement. It Works like as if else if nested conditional statement.But the Advantage of using Switch case over if else if nested conditional statement Management of switch case is easy
See Switch case example below that how work switch statement:


Switch case in program c++ example


#include
using namespace std;
int main()
{
char op;
long  a,b,r;

cout cin>> a;
 cin>>b;
cout cin>>op>>endl;
switch(op)
{
case '+':
         r=a+b;
         cout break;
case '-':
r=a-b;
        cout break;
case '*':
r=a*b;
        cout break;
case '/':
        r=a/b;
        cout break;
default:
cout }
return 0;
}


Output: Enter two number to calculate:
             10
              4
Please chooese a operator +, -, *, /
              +
10 + 4 =14


   
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 »

Monday, February 5, 2018

Switch case program in c with example

Hello friends! Welcome to my blog

Today we discuss How to use switch case conditional statement in c and how to program switch case in c programming examples

What is switch Case?

Switch case is a multi-way conditional statement. It Works like as if else if nested conditional statement.But the Advantage of using Switch case over if else if nested conditional statement Management of switch case is easy

See Switch case example below that how work switch statement:

Switch case in c programming example




    #include
    #include
    main()
    {
        char op;
        long  a,b;
        clrscr();
         printf("Enter two number to calculate: \n");
         scanf("%l\t%l",&a,&b);
         printf("Please chooese a operator +, -, *, /");
         scanf("%f",&op);
         switch(op)
         {
            case '+':
                  printf("%l + %l = %l",a,b,a+b);
                 break;
         case '-':
                 printf("%l - %l = %l",a,b,a-b);
                  break;
        case '*':
                printf("%l * %l = %l",a,b,a*b);
                 break;
         case '/':
printf("%l / %l = %l",a,b,a/b);
break;
default:
printf("Enter valid operator\n");
}
getch();
     }


Output: Enter two number to calculate:
             10  4
Please chooese a operator +, -, *, /
              +
10 + 4 =14
     

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 any query email programmingshortcut@gmail.com

Please comment your experience on this post,
Thank You!

      
More Code »

Friday, February 2, 2018

Program to swap two numbers in java

Hello friends! Welcome to my blog
Here we discuss how to swap two numbers in java language and there are two methods to swap two numbers in java

1. swap two numbers without using third variable in java.

2. swap two numbers with using third variable in java.

See Example below

Swap two numbers without temp in java


import java.util.Scanner;
public class swap_without {
    public static void main(String[] args) {
       int a ,b;
        Scanner in = new Scanner(System.in);
        System.out.println("Enter the two number");
        a=in.nextInt();
        b=in.nextInt();
        System.out.println("Number before Swap:\n a="+a+"\n b="+b);
        a=a+b;
        b=a-b;
        a=a-b;
        System.out.println("Number After Swap:\n a="+a+"\n b="+b);
    }
}


Enter the two number
4
6
Number before Swap:
 a=4
 b=6
Number After Swap:
 a=6
 b=4



Swap two numbers in java


import java.util.Scanner;
public class swap {
    public static void main(String[] args) {
        int a ,b;
        Scanner in = new Scanner(System.in);
        System.out.println("Enter the two number");
        a=in.nextInt();
        b=in.nextInt();
        System.out.println("Number Before Swap:\n a="+a+"\n b="+b);
        int temp=a;
        a=b;
        b=temp;
        System.out.println("Number After Swap:\n a="+a+"\n b="+b);
 
    }
}


Enter the two number
4
7
Number Before Swap:
 a=4
 b=7
Number After Swap:
 a=7
 b=4


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 Shortcuts

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

Monday, January 29, 2018

how to swap two numbers without temp program in c++

Hello friends! Welcome to my website

Today we show you how to swap two numbers without temp or how to swap two numbers without using third variable in c++ and c++ program to swap two numbers. how to swap two number in cpp with using third variable and swap with third variable


How to swap two numbers without using third variable in c++


#include
using namespace std;
int main() {

int a,b;

cout cin>>a;
cin>>b;
cout a=a+b;
b=a-b;
a=a-b;
cout return 0;
}


  Output: Enter two numbers:
     4
   5
  Before swap:
   a=4
   b=5
  After swap:
   a=5
   b=4


C program to swap two numbers


#include
using namespace std;
int main() {

int a,b,temp;

cout cin>>a;
cin>>b;
cout temp=a;
a=b;
b=temp;
cout return 0;
}


  Output: Enter two numbers:
     4
   5
  Before swap:
   a=4
   b=5
  After swap:
   a=5
   b=4



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 share your experience about this post,
Thank You!

More Code »

Tuesday, January 23, 2018

how to swap two numbers without temp in c

Hello friends! Welcome to my website

Today we show you how to swap two numbers without temp or how to swap two numbers without using third variable in c and c program to swap two numbers and how to swap two numbers in c language programming.

How to swap two numbers without using third variable in c


#include
#include
void main(){
int a,b;
clrscr();
printf("Enter two numbers\n");
sacnf("%d",&a);
sacnf("%d",&b);
printf("Before swap:\n a=%d \n b=%d",a,b);
a=a+b;
b=a-b;
a=a-b;
printf("After swap:\n a=%d \n b=%d",a,b);
getch();
}



  Output: Enter two numbers:
    4
   5
  Before swap:
   a=4
   b=5
  After swap:
   a=5
   b=4



C program to swap two numbers



#include
#include
void main(){
int a,b,temp;
clrscr();
printf("Enter two numbers\n");
sacnf("%d",&a);
sacnf("%d",&b);
printf("Before swap:\n a=%d \n b=%d",a,b);
temp=a;
b=a;
a=temp;
printf("After swap:\n a=%d \n b=%d",a,b);
getch();
}


  Output: Enter two numbers:
    4
   5
  Before swap:
   a=4
   b=5
  After swap:
   a=5
   b=4



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 any query email programmingshortcut@gmail.com

Please comment your experience on this post,
Thank You!
More Code »

Sunday, January 21, 2018

C++ program for Fibonacci series

Hello friends! Welcome to my website

Program to generate Fibonacci series programming in c++. How to use for loop in c++ language for example
In this Fibonacci series, each number is a sum of the previous two numbers. fibonacci series programming c++ , Fibonacci series c++ programming, Fibonacci series c++ code in c++ session

How to print Fibonacci series programming in c++


    #include
    using namespace std;

    int main() {
        long x, y, z;
        int i, n;
        x = 0;
        y = 1;
        cout         cin>>n;
        cout         for (i = 1; i             z = x + y;
            cout             x = y;
            y = z;
        }
        cout return 0;
    }


Output: Enter the number of terms: 10
        1, 1, 2, 3, 5, 8, 13, 21, 34, 55,


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 »

Monday, January 15, 2018

Fibonacci series programming in java

Hello friends! Welcome to my website

Program to generate Fibonacci series programming in java. How to use for loop in java language with example
In this Fibonacci series, each number is a sum of the previous two numbers. fibonacci series programming java, Fibonacci series java programming, Fibonacci series java code in java session

How to print Fibonacci series programming in java


import java.util.Scanner;
public class fibonacci {
    public static void main(String[] args) {
        Scanner c = new Scanner(System.in);
        long x, y, z;
        int i, n;
        x = 0;
        y = 1;
        System.out.print("Enter the number of terms : ");
        n = c.nextInt();
        System.out.print(y+", ");
        for (i = 1; i             z = x + y;
            System.out.print(z+", ");
            x = y;
            y = z;
        }
        System.out.print(" ");
    }
}


Output: Enter the number of terms: 10
        1, 1, 2, 3, 5, 8, 13, 21, 34, 55,


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 »

Saturday, January 6, 2018

fibonacci series programming c

Hello friends! Welcome to my website

Program to generate fibonacci series programming in c. How to use for loop in c language with example
In this fibonacci series each number is a sum of the previous two numbers. fibonacci series programming c, fibonacci series c programming, fibonacci series c code in c  session

How to print fibonacci series programming in c


#include
#include
void main()
{
long x,y,z;
int i,n;
x=0;
y=1;
printf("Enter the number of terms : ");
scanf("%d",&n);
printf("%ld ",y);
for(i=1; i {
z=x+y;
printf("%ld, ",z);
x=y;
y=z;
}
printf("\n");
getch();
}


Output: 
1, 1, 2, 3, 5, 8, 13, 34, 55, 89...................



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 any query email programmingshortcut@gmail.com

Please comment your experience on this post,
Thank You!

More Code »

Thursday, January 4, 2018

Even and odd numbers list betwwen 1 to n in java

Hello friends! Welcome to my website

This session shows how to print all even and odd numbers list between 1 to n by oops concepts in java
This java language programming is free all type of errors like the compiler and runtime errors and this programming is tested to compile and then run the program code.
Here is only programming code with the output. This programming output is customized to understand easily.


Print all even numbers between 1 to n in Java 


import java.util.Scanner;
class test1 {
int n;
public void printeven(int n) {
int i =0;
while ( i if(i%2==0){
System.out.print(i+" ");
}
i++;
}
}
}
public class evenlist {
public static void main(String[] args) {
test1 o = new test1();
Scanner c= new Scanner(System.in);
System.out.print("Enter a Number till want list:");
o.n=c.nextInt();
System.out.println("All Even Number list");
o.printeven(o.n);
}
}


Output:    Enter a Number till want list: 20
All Even Number list
0 2 4 6 8 10 12 14 16 18



Print all odd numbers between 1 to n in Java 


import java.util.Scanner;
class test1 {
int n;
public void printSum(int n) {
int i = 0;
while (i if (i % 2 == 1) {
System.out.print(i + " ");
}
i++;
}
}
}
public class even_and_odd {
public static void main(String[] args) {
test1 o = new test1();
Scanner c = new Scanner(System.in);
System.out.print("Enter a Number till want list: ");
o.n = c.nextInt();
System.out.println("All Odd Number list");
o.printSum(o.n);
}
}


Output:  Enter a Number till want list: 20
All Odd Number list
1 3 5 7 9 11 13 15 17 19

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 »

List of even and odd numbers list 1 to n in c++

Hello friends! Welcome to my website

Today We Run a program to print all even and odd numbers lists in oops concepts in c++.
This session is how to print the even or odd numbers list in c++ Programming. Here we show you, how to use while loop and if loop programming with Example and oops concepts in c++
This c++ language programming is free all type of errors like the compiler and runtime errors and this programming is tested to compile and then run the program code.
Here is only programming code with the output. This programming output is customized to understand easily.


Print all even numbers between 1 to n in c++

#include
#include
using namespace std;
class test1 {
public:
int n;
void printeven(int n) {
int i =0;
while ( i if(i%2==0){
cout }
i++;
}
}
}
int main() {

test1 o ;
cout cin>>o.n;
cout o.printeven(o.n);
}


Output:    Enter a Number till want list: 20
All Even Number list
0 2 4 6 8 10 12 14 16 18


Print all odd numbers between 1 to n in c++

#include
#include
using namespace std;
class test1 {
public:
int n;
void printeven(int n) {
int i =0;
while ( i if(i%2==1){
cout }
i++;
}
}
}
int main() {

test1 o ;
cout cin>>o.n;
cout o.printeven(o.n);
}


Output:    Enter a Number till want list: 20
All Odd Number list
1 3 5 7 9 11 13 15 17 19

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 share your experience about this post,
Thank You!

More Code »

Monday, January 1, 2018

Print 1 to n even and odd number in c

Hello friends! Welcome to my website

Today We Run a program to print 1 to n even numbers and odd number in c programming. Here I show you, how use of while loop in c programming with Example
This c language programming is free all type of errors like the compiler and runtime errors and this programming is tested to compile and then run the program code.
Here is only programming code with the output. This programming output is customized to understand easily.


Print 1 to n even numbers in c 


#include
#include
void main();{
    int n, i=0;
clrscr();
printf ("Enter a number to want to print odd no. list: ");
scanf("%d",&n);
printf("The Even Numbers list is:\n");
while(i if((i%2)==0){
printf("%d\t", n);
}
i++;
}
  getch();
 }


Output: Enter a number to want to print even no. list: 10
              The Even Numbers list is:
             0 2 4 6 8


Print 1 to n odd numbers  in c 


#include
#include
void main();{
    int n, i=0;
clrscr();
printf ("Enter a number to want to print odd no. list: ");
scanf("%d",&n);
printf("The odd Numbers list is:\n");
while(i if((i%2)==1){
printf("%d\t", n);
}
i++;
}
    getch();
}


Output: Enter a number to want to print odd no. list: 10
              The odd Numbers list is:
              1 3 5 7 9


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 any query email programmingshortcut@gmail.com

Please comment your experience on this post,
Thank You!

More Code »
Newer Posts Older Posts Home

Programming Shortcut is collections in java best programs with example, best c programs with example and best c++ programs with example, best way to learn java, c and c++

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