Monday, November 3, 2014
Friday, October 31, 2014
To find wheather the girl you love will be girlfriend or not using C
4:07 PM
No comments
#include<stdio.h>
int main ( )
{
char rply;
printf("Propose the girl you love: \n");
printf("enter the answer ( y for yes and n for no):");
scanf("%c",& rply);
if(rply=='y')
printf("She is your girlfriend now");
if(rply=='n')
{
printf("She is not your girlfriend \n");
printf("Keep trying");
}
return 0;
}
int main ( )
{
char rply;
printf("Propose the girl you love: \n");
printf("enter the answer ( y for yes and n for no):");
scanf("%c",& rply);
if(rply=='y')
printf("She is your girlfriend now");
if(rply=='n')
{
printf("She is not your girlfriend \n");
printf("Keep trying");
}
return 0;
}
Wednesday, October 29, 2014
How to find the fibonacci series using C and java
7:47 AM
No comments
UAING C
#include<stdio.h>
int main()
{
int i, fibi1, fibi2, fibi3;
int k=5 ;
fibi1 = 0;
fibi2 = 1;
printf( "The Fibonacci numbers are: " );
printf( "%d \t %d \t", fibi1, fibi2 );
for(i=0; i<k-2 ;i++)
{
fibi3= fibi1 + fibi2;
fibi1=fibi2;
fibi2=fibi3;
printf("%d \t", fibi3);
}
return 0;
}
USING JAVA
import java.util.Scanner;
{
static Scanner sc= new Scanner(System.in);
public static void main(String[] args)
{
int fibonacci = 5;
int[] fibo = new int[fibonacci];
fibo[0] = 0;
fibo[1] = 1;
System.out.print("The Fibonacci numbers are: ");
System.out.print(" " + fibo[0] + " " + fibo[1]);
for(int i=2; i < fibonacci; i++)
{
fibo[i] = fibo[i-1] + fibo[i-2];
System.out.print(" " + fibo[i]);
}
}
}
..........................................................................................................
in both java and c the output will be
The Fibonacci numbers are: 0 1 1 2 3
...........................................................................................................
IF WE WANT THE USER TO INPUT THE NUMBERS:
USING C
#include<stdio.h>
int main()
{
int i, fibi1, fibi2, fibi3, k;
fibi1 = 0;
fibi2 = 1;
printf("enter the number of fibonacci numbers to generate: ");
scanf( "%d", &k );
printf( "The Fibonacci numbers are: " );
printf( "%d \t %d \t", fibi1, fibi2 );
for(i=0; i<k-2 ;i++)
{
fibi3= fibi1 + fibi2;
fibi1=fibi2;
fibi2=fibi3;
printf("%d \t", fibi3);
}
return 0;
}
USING JAVA
import java.util.Scanner;
{
static Scanner sc= new Scanner(System.in);
public static void main(String[] args)
{
int fibonacci;
System.out.print("enter the number of fibonacci numbers to generate:");
fibonacci= sc.nextInt();
int[] fibo = new int[fibonacci];
fibo[0] = 0;
fibo[1] = 1;
System.out.print("The Fibonacci numbers are: ");
System.out.print(" " + fibo[0] + " " + fibo[1]);
for(int i=2; i < fibonacci; i++)
{
fibo[i] = fibo[i-1] + fibo[i-2];
System.out.print(" " + fibo[i]);
}
}
}
#include<stdio.h>
int main()
{
int i, fibi1, fibi2, fibi3;
int k=5 ;
fibi1 = 0;
fibi2 = 1;
printf( "The Fibonacci numbers are: " );
printf( "%d \t %d \t", fibi1, fibi2 );
for(i=0; i<k-2 ;i++)
{
fibi3= fibi1 + fibi2;
fibi1=fibi2;
fibi2=fibi3;
printf("%d \t", fibi3);
}
return 0;
}
USING JAVA
import java.util.Scanner;
{
static Scanner sc= new Scanner(System.in);
public static void main(String[] args)
{
int fibonacci = 5;
int[] fibo = new int[fibonacci];
fibo[0] = 0;
fibo[1] = 1;
System.out.print("The Fibonacci numbers are: ");
System.out.print(" " + fibo[0] + " " + fibo[1]);
for(int i=2; i < fibonacci; i++)
{
fibo[i] = fibo[i-1] + fibo[i-2];
System.out.print(" " + fibo[i]);
}
}
}
..........................................................................................................
in both java and c the output will be
The Fibonacci numbers are: 0 1 1 2 3
...........................................................................................................
IF WE WANT THE USER TO INPUT THE NUMBERS:
USING C
#include<stdio.h>
int main()
{
int i, fibi1, fibi2, fibi3, k;
fibi1 = 0;
fibi2 = 1;
printf("enter the number of fibonacci numbers to generate: ");
scanf( "%d", &k );
printf( "The Fibonacci numbers are: " );
printf( "%d \t %d \t", fibi1, fibi2 );
for(i=0; i<k-2 ;i++)
{
fibi3= fibi1 + fibi2;
fibi1=fibi2;
fibi2=fibi3;
printf("%d \t", fibi3);
}
return 0;
}
USING JAVA
import java.util.Scanner;
{
static Scanner sc= new Scanner(System.in);
public static void main(String[] args)
{
int fibonacci;
System.out.print("enter the number of fibonacci numbers to generate:");
fibonacci= sc.nextInt();
int[] fibo = new int[fibonacci];
fibo[0] = 0;
fibo[1] = 1;
System.out.print("The Fibonacci numbers are: ");
System.out.print(" " + fibo[0] + " " + fibo[1]);
for(int i=2; i < fibonacci; i++)
{
fibo[i] = fibo[i-1] + fibo[i-2];
System.out.print(" " + fibo[i]);
}
}
}
Monday, October 27, 2014
How to swap any two numbers using C and java
12:21 PM
No comments
USING C
#include<stdio.h>
#include<conio.h>
int main()
{
int x,y,z;
x=5;
y=6;
z=x;
x=y;
y=z;
printf(" the new first no is: %d ", x);
printf(" the new second no is: %d ", y);
// %d is use of integer type variables//
return 0;
}
USING JAVA
public static void main(String[] args)
{
int firstvalue = 5;
int secondvalue = 6;
int x = firstvalue;
firstvalue = secondvalue;
secondvalue = x;
System.out.println(" the new first no is: " + firstvalue);
System.out.println(" the new second no is: " + secondvalue);
}
..........................................................................................................
in both java and c the output will be
the new first no is: 6
the new second no is: 5
...........................................................................................................
IF WE WANT THE USER TO INPUT THE NUMBERS:
USING C
#include<stdio.h>
#include<conio.h>
int main()
{
int x,y,z;
printf("Enter the first number:");
scanf("%d", &x);
printf("Enter the second number:");
scanf("%d", &y);
z=x;
x=y;
y=z;
printf(" the new first no is: %d ", x);
printf(" the new second no is: %d ", y);
// %d is use of integer type variables//
return 0;
}
USING JAVA
import java.util.Scanner;
{
static Scanner sc= new Scanner(System.in);
public static void main(String[] args)
{
int firstvalue;
int secondvalue;
System.out.print("Enter the first number:");
firstvalue= sc.nextInt();
System.out.print("Enter the Second number:");
secondvalue=sc.nextInt();
int z = firstvalue ;
firstvalue = secondvalue;
secondvalue = z;
System.out.println("the new first no is:" + firstvalue);
System.out.println("the new second no is:" + secondvalue);
}
}
Steps to construct a binary tree [data structure]
8:13 AM
No comments
Traversing of Binary tree can be done by as
(1) Preorder Traversing
(2) Inorder Traversing
(3) Postorder Traversing
Preorder traversal Steps
(1) Visit the root
(2) Traverse the left sub-tree in preorder
(3) Traverse the right sub-tree in preorder
Inorder traversal Steps
(1) Traverse the left sub-tree in inorder
(2) Visit the root
(3) Traverse the right sub-tree in inorder
Postorder traversal Steps
(1) Traverse the left sub-tree in postorder
(2) Traverse the right sub-tree in postorder
(3) Visit the root
(1) Preorder Traversing
(2) Inorder Traversing
(3) Postorder Traversing
Preorder traversal Steps
(1) Visit the root
(2) Traverse the left sub-tree in preorder
(3) Traverse the right sub-tree in preorder
Inorder traversal Steps
(1) Traverse the left sub-tree in inorder
(2) Visit the root
(3) Traverse the right sub-tree in inorder
Postorder traversal Steps
(1) Traverse the left sub-tree in postorder
(2) Traverse the right sub-tree in postorder
(3) Visit the root
Draw a binary search tree from the given sequence list the nodes in preorder traversal and inorder traversal [data structure]
2:05 AM
No comments
The following given sequences list the nodes of a binary search tree in preorder and inorder respectively
preorder: G, B, Q, A, C, K, F, P, D, E, R, H
inorder: Q, B, K, C, F, A, G, P, E, D, H, R
Sunday, October 26, 2014
Fun Magic programme
2:35 AM
No comments
USING C
#include<stdio.h>
#include<conio.h>
int main()
{
int z;
printf("Enter the number you want but don't say it to others:");
scanf("%d",&z);
printf("I can say the number you input without knowing it :-P \n");
printf("The number is: %d \n", z);
printf("lol :-P :-P ");
return 0
}
USING JAVA
import java.util.Scanner;
{
static Scanner sc= new Scanner(System.in);
public static void main(String[] args)
{
int result;
System.out.print("Enter the number you want but don't say it to others:");
result= sc.nextInt();
System.out.print("I can say the number you input without knowing it :-P \n");
System.out.println("The number is: " + result);
System.out.print("\n lol :-P :-P :");
}
}
#include<stdio.h>
#include<conio.h>
int main()
{
int z;
printf("Enter the number you want but don't say it to others:");
scanf("%d",&z);
printf("I can say the number you input without knowing it :-P \n");
printf("The number is: %d \n", z);
printf("lol :-P :-P ");
return 0
}
USING JAVA
import java.util.Scanner;
{
static Scanner sc= new Scanner(System.in);
public static void main(String[] args)
{
int result;
System.out.print("Enter the number you want but don't say it to others:");
result= sc.nextInt();
System.out.print("I can say the number you input without knowing it :-P \n");
System.out.println("The number is: " + result);
System.out.print("\n lol :-P :-P :");
}
}
How to find the Simple interest using C and java
2:07 AM
No comments
USING C
#include<stdio.h>
#include<conio.h>
int main()
{
int principal,rate,timeperiod,simpleinerest;
principal=1000;
rate=3;
timeperiod=4;
simpleinterest=(principal*rate*timeperiod)/100;
printf(" the simple interest is: %d ", simpleinterest);
// %d is use of integer type variables//
return 0;
}
USING JAVA
public static void main(String[] args)
{
int principal = 1000;
int rate = 3;
int timeperiod=4
int simpleinterest = (principal * rate * timeperiod)/100 ;
System.out.println("the simple interest is: " + simpleinterest);
}
..........................................................................................................
in both java and c the output will be
the result is: 120
...........................................................................................................
IF WE WANT THE USER TO INPUT THE NUMBERS:
USING C
#include<stdio.h>
#include<conio.h>
int main()
{
int w,y;
float x,z;
printf("enter the principal money:");
scanf("%d", &w);
printf("Enter the rate:");
scanf("%d", &x);
printf("Enter the time period:");
scanf("%d",&y);
z=(w*x*y)/100;
printf(" the simple interest is: %d ", z);
// %d is use of integer type variables//
return 0;
}
USING JAVA
import java.util.Scanner;
{
static Scanner sc= new Scanner(System.in);
public static void main(String[] args)
{
int firstvalue;
int secondvalue;
float thirdvalue;
System.out.print("Enter the principal money:");
firstvalue= sc.nextInt();
System.out.print("Enter the time period:");
secondvalue=sc.nextInt();
System.out.print("Enter the rate:");
thirdvalue=sc.nextInt();
float result = (firstvalue * secondvalue * thirdvalue)/100 ;
System.out.println("the simple intereste is:" + result);
}
}
#include<stdio.h>
#include<conio.h>
int main()
{
int principal,rate,timeperiod,simpleinerest;
principal=1000;
rate=3;
timeperiod=4;
simpleinterest=(principal*rate*timeperiod)/100;
printf(" the simple interest is: %d ", simpleinterest);
// %d is use of integer type variables//
return 0;
}
USING JAVA
public static void main(String[] args)
{
int principal = 1000;
int rate = 3;
int timeperiod=4
int simpleinterest = (principal * rate * timeperiod)/100 ;
System.out.println("the simple interest is: " + simpleinterest);
}
..........................................................................................................
in both java and c the output will be
the result is: 120
...........................................................................................................
IF WE WANT THE USER TO INPUT THE NUMBERS:
USING C
#include<stdio.h>
#include<conio.h>
int main()
{
int w,y;
float x,z;
printf("enter the principal money:");
scanf("%d", &w);
printf("Enter the rate:");
scanf("%d", &x);
printf("Enter the time period:");
scanf("%d",&y);
z=(w*x*y)/100;
printf(" the simple interest is: %d ", z);
// %d is use of integer type variables//
return 0;
}
USING JAVA
import java.util.Scanner;
{
static Scanner sc= new Scanner(System.in);
public static void main(String[] args)
{
int firstvalue;
int secondvalue;
float thirdvalue;
System.out.print("Enter the principal money:");
firstvalue= sc.nextInt();
System.out.print("Enter the time period:");
secondvalue=sc.nextInt();
System.out.print("Enter the rate:");
thirdvalue=sc.nextInt();
float result = (firstvalue * secondvalue * thirdvalue)/100 ;
System.out.println("the simple intereste is:" + result);
}
}
Saturday, October 25, 2014
How to find the area of a square using C and java
3:27 PM
No comments
USING C
#include<stdio.h>
#include<conio.h>
int main()
{
int side,area;
side=4;
area=side*side;
printf(" the area of the square is: %d ", area);
// %d is use of integer type variables//
return 0;
}
USING JAVA
public static void main(String[] args)
{
int side = 4;
int area = side * side ;
System.out.println("the area of the square is: " + area);
}
..........................................................................................................
in both java and c the output will be
the result is: 16
...........................................................................................................
IF WE WANT THE USER TO INPUT THE NUMBERS:
USING C
#include<stdio.h>
#include<conio.h>
int main()
{
int x,z;
printf("enter the side:");
scanf("%d", &x);
z=x*x;
printf(" the area of the square is: %d ", z);
// %d is use of integer type variables//
return 0;
}
USING JAVA
import java.util.Scanner;
{
static Scanner sc= new Scanner(System.in);
public static void main(String[] args)
{
int firstvalue;
System.out.print("Enter the side:");
firstvalue= sc.nextInt();
int result = firstvalue * firstvalue ;
System.out.println("the area of the square is:" + result);
}
}
#include<stdio.h>
#include<conio.h>
int main()
{
int side,area;
side=4;
area=side*side;
printf(" the area of the square is: %d ", area);
// %d is use of integer type variables//
return 0;
}
USING JAVA
public static void main(String[] args)
{
int side = 4;
int area = side * side ;
System.out.println("the area of the square is: " + area);
}
..........................................................................................................
in both java and c the output will be
the result is: 16
...........................................................................................................
IF WE WANT THE USER TO INPUT THE NUMBERS:
USING C
#include<stdio.h>
#include<conio.h>
int main()
{
int x,z;
printf("enter the side:");
scanf("%d", &x);
z=x*x;
printf(" the area of the square is: %d ", z);
// %d is use of integer type variables//
return 0;
}
USING JAVA
import java.util.Scanner;
{
static Scanner sc= new Scanner(System.in);
public static void main(String[] args)
{
int firstvalue;
System.out.print("Enter the side:");
firstvalue= sc.nextInt();
int result = firstvalue * firstvalue ;
System.out.println("the area of the square is:" + result);
}
}
How to find the area of a triangle using C and java
3:17 PM
No comments
USING C
#include<stdio.h>
#include<conio.h>
int main()
{
int height,base,area;
height=4;
base=3;
area=(height*base)/2;
printf(" the area of the triangle is: %d ", area);
// %d is use of integer type variables//
return 0;
}
USING JAVA
public static void main(String[] args)
{
int height = 4;
int base = 3;
int area = (height * base)/2 ;
System.out.println("the area of the triangle is: " + area);
}
..........................................................................................................
in both java and c the output will be
the result is: 6
...........................................................................................................
IF WE WANT THE USER TO INPUT THE NUMBERS:
USING C
#include<stdio.h>
#include<conio.h>
int main()
{
int x,y,z;
printf("enter the height:");
scanf("%d", &x);
printf("Enter the base:");
scanf("%d", &y);
z=(x*y)/2;
printf(" the area of the triangle is: %d ", z);
// %d is use of integer type variables//
return 0;
}
USING JAVA
import java.util.Scanner;
{
static Scanner sc= new Scanner(System.in);
public static void main(String[] args)
{
int firstvalue;
int secondvalue;
System.out.print("Enter the height:");
firstvalue= sc.nextInt();
System.out.print("Enter the base:");
secondvalue=sc.nextInt();
int result = (firstvalue * secondvalue)/2 ;
System.out.println("the area of the triangle is:" + result);
}
}
#include<stdio.h>
#include<conio.h>
int main()
{
int height,base,area;
height=4;
base=3;
area=(height*base)/2;
printf(" the area of the triangle is: %d ", area);
// %d is use of integer type variables//
return 0;
}
USING JAVA
public static void main(String[] args)
{
int height = 4;
int base = 3;
int area = (height * base)/2 ;
System.out.println("the area of the triangle is: " + area);
}
..........................................................................................................
in both java and c the output will be
the result is: 6
...........................................................................................................
IF WE WANT THE USER TO INPUT THE NUMBERS:
USING C
#include<stdio.h>
#include<conio.h>
int main()
{
int x,y,z;
printf("enter the height:");
scanf("%d", &x);
printf("Enter the base:");
scanf("%d", &y);
z=(x*y)/2;
printf(" the area of the triangle is: %d ", z);
// %d is use of integer type variables//
return 0;
}
USING JAVA
import java.util.Scanner;
{
static Scanner sc= new Scanner(System.in);
public static void main(String[] args)
{
int firstvalue;
int secondvalue;
System.out.print("Enter the height:");
firstvalue= sc.nextInt();
System.out.print("Enter the base:");
secondvalue=sc.nextInt();
int result = (firstvalue * secondvalue)/2 ;
System.out.println("the area of the triangle is:" + result);
}
}
How to find the area of a rectangle using C and java
3:10 PM
No comments
USING C
#include<stdio.h>
#include<conio.h>
int main()
{
int length,width,area;
length=4;
width=3;
area=length*width;
printf(" the area of the rectangle is: %d ", area);
// %d is use of integer type variables//
return 0;
}
USING JAVA
public static void main(String[] args)
{
int length = 4;
int width = 3;
int area = length * width ;
System.out.println("the area of the rectangle is: " + area);
}
..........................................................................................................
in both java and c the output will be
the result is: 12
...........................................................................................................
IF WE WANT THE USER TO INPUT THE NUMBERS:
USING C
#include<stdio.h>
#include<conio.h>
int main()
{
int x,y,z;
printf("enter the length:");
scanf("%d", &x);
printf("Enter the width:");
scanf("%d", &y);
z=x*y;
printf(" the area of the rectangle is: %d ", z);
// %d is use of integer type variables//
return 0;
}
USING JAVA
import java.util.Scanner;
{
static Scanner sc= new Scanner(System.in);
public static void main(String[] args)
{
int firstvalue;
int secondvalue;
System.out.print("Enter the length:");
firstvalue= sc.nextInt();
System.out.print("Enter the width:");
secondvalue=sc.nextInt();
int result = firstvalue * secondvalue ;
System.out.println("the area of the rectangle is:" + result);
}
}
#include<stdio.h>
#include<conio.h>
int main()
{
int length,width,area;
length=4;
width=3;
area=length*width;
printf(" the area of the rectangle is: %d ", area);
// %d is use of integer type variables//
return 0;
}
USING JAVA
public static void main(String[] args)
{
int length = 4;
int width = 3;
int area = length * width ;
System.out.println("the area of the rectangle is: " + area);
}
..........................................................................................................
in both java and c the output will be
the result is: 12
...........................................................................................................
IF WE WANT THE USER TO INPUT THE NUMBERS:
USING C
#include<stdio.h>
#include<conio.h>
int main()
{
int x,y,z;
printf("enter the length:");
scanf("%d", &x);
printf("Enter the width:");
scanf("%d", &y);
z=x*y;
printf(" the area of the rectangle is: %d ", z);
// %d is use of integer type variables//
return 0;
}
USING JAVA
import java.util.Scanner;
{
static Scanner sc= new Scanner(System.in);
public static void main(String[] args)
{
int firstvalue;
int secondvalue;
System.out.print("Enter the length:");
firstvalue= sc.nextInt();
System.out.print("Enter the width:");
secondvalue=sc.nextInt();
int result = firstvalue * secondvalue ;
System.out.println("the area of the rectangle is:" + result);
}
}
Thursday, October 23, 2014
How to divide two numbers using C and java
8:29 AM
No comments
USING C
#include<stdio.h>
#include<conio.h>
int main()
{
int x,y,z;
x=6;
y=6;
z=x/y;
printf(" the result is: %d ", z);
// %d is use of integer type variables//
return 0;
}
USING JAVA
public static void main(String[] args)
{
int firstvalue = 6;
int secondvalue = 6;
int result = firstvalue / secondvalue ;
System.out.println("the result is: " + result);
}
..........................................................................................................
in both java and c the output will be
the result is: 1
...........................................................................................................
IF WE WANT THE USER TO INPUT THE NUMBERS:
USING C
#include<stdio.h>
#include<conio.h>
int main()
{
int x,y,z;
printf("enter the first value:");
scanf("%d", &x);
printf("Enter the second value:");
scanf("%d", &y);
z=x/y;
printf(" the result is: %d ", z);
// %d is use of integer type variables//
return 0;
}
USING JAVA
import java.util.Scanner;
{
static Scanner sc= new Scanner(System.in);
public static void main(String[] args)
{
int firstvalue;
int secondvalue;
System.out.print("Enter the first value:");
firstvalue= sc.nextInt();
System.out.print("Enter the Second value:");
secondvalue=sc.nextInt();
int result = firstvalue / secondvalue ;
System.out.println("the result of is:" + result);
}
}
#include<stdio.h>
#include<conio.h>
int main()
{
int x,y,z;
x=6;
y=6;
z=x/y;
printf(" the result is: %d ", z);
// %d is use of integer type variables//
return 0;
}
USING JAVA
public static void main(String[] args)
{
int firstvalue = 6;
int secondvalue = 6;
int result = firstvalue / secondvalue ;
System.out.println("the result is: " + result);
}
..........................................................................................................
in both java and c the output will be
the result is: 1
...........................................................................................................
IF WE WANT THE USER TO INPUT THE NUMBERS:
USING C
#include<stdio.h>
#include<conio.h>
int main()
{
int x,y,z;
printf("enter the first value:");
scanf("%d", &x);
printf("Enter the second value:");
scanf("%d", &y);
z=x/y;
printf(" the result is: %d ", z);
// %d is use of integer type variables//
return 0;
}
USING JAVA
import java.util.Scanner;
{
static Scanner sc= new Scanner(System.in);
public static void main(String[] args)
{
int firstvalue;
int secondvalue;
System.out.print("Enter the first value:");
firstvalue= sc.nextInt();
System.out.print("Enter the Second value:");
secondvalue=sc.nextInt();
int result = firstvalue / secondvalue ;
System.out.println("the result of is:" + result);
}
}
How to multiply two numbers using C and java
8:28 AM
No comments
USING C
#include<stdio.h>
#include<conio.h>
int main()
{
int x,y,z;
x=6;
y=6;
z=x*y;
printf(" the result of is: %d ", z);
// %d is use of integer type variables//
return 0;
}
USING JAVA
public static void main(String[] args)
{
int firstvalue = 6;
int secondvalue = 6;
int result = firstvalue * secondvalue ;
System.out.println(" the result of is: " + result);
}
..........................................................................................................
in both java and c the output will be
the summation is: 36
...........................................................................................................
IF WE WANT THE USER TO INPUT THE NUMBERS:
USING C
#include<stdio.h>
#include<conio.h>
int main()
{
int x,y,z;
printf("enter the first value:");
scanf("%d", &x);
printf("Enter the second value:");
scanf("%d", &y);
z=x*y;
printf(" the result of is: %d ", z);
// %d is use of integer type variables//
return 0;
}
USING JAVA
import java.util.Scanner;
{
static Scanner sc= new Scanner(System.in);
public static void main(String[] args)
{
int firstvalue;
int secondvalue;
System.out.print("Enter the first value:");
firstvalue= sc.nextInt();
System.out.print("Enter the Second value:");
secondvalue=sc.nextInt();
int result = firstvalue * secondvalue ;
System.out.println("the result of is:" + result);
}
}
#include<stdio.h>
#include<conio.h>
int main()
{
int x,y,z;
x=6;
y=6;
z=x*y;
printf(" the result of is: %d ", z);
// %d is use of integer type variables//
return 0;
}
USING JAVA
public static void main(String[] args)
{
int firstvalue = 6;
int secondvalue = 6;
int result = firstvalue * secondvalue ;
System.out.println(" the result of is: " + result);
}
..........................................................................................................
in both java and c the output will be
the summation is: 36
...........................................................................................................
IF WE WANT THE USER TO INPUT THE NUMBERS:
USING C
#include<stdio.h>
#include<conio.h>
int main()
{
int x,y,z;
printf("enter the first value:");
scanf("%d", &x);
printf("Enter the second value:");
scanf("%d", &y);
z=x*y;
printf(" the result of is: %d ", z);
// %d is use of integer type variables//
return 0;
}
USING JAVA
import java.util.Scanner;
{
static Scanner sc= new Scanner(System.in);
public static void main(String[] args)
{
int firstvalue;
int secondvalue;
System.out.print("Enter the first value:");
firstvalue= sc.nextInt();
System.out.print("Enter the Second value:");
secondvalue=sc.nextInt();
int result = firstvalue * secondvalue ;
System.out.println("the result of is:" + result);
}
}
How to Substruct two numbers using C and java
4:05 AM
No comments
USING C
#include<stdio.h>
#include<conio.h>
int main()
{
int x,y,z;
x=17;
y=6;
z=x-y;
printf(" the result is: %d ", z);
// %d is use of integer type variables//
return 0;
}
USING JAVA
public static void main(String[] args)
{
int firstvalue = 17;
int secondvalue = 6;
int result = firstvalue - secondvalue ;
System.out.println("the result is: " + result);
}
..........................................................................................................
in both java and c the output will be
the result is: 11
...........................................................................................................
IF WE WANT THE USER TO INPUT THE NUMBERS:
USING C
#include<stdio.h>
#include<conio.h>
int main()
{
int x,y,z;
printf("enter the first value:");
scanf("%d", &x);
printf("Enter the second value:");
scanf("%d", &y);
z=x-y;
printf(" the result is: %d ", z);
// %d is use of integer type variables//
return 0;
}
USING JAVA
import java.util.Scanner;
{
static Scanner sc= new Scanner(System.in);
public static void main(String[] args)
{
int firstvalue;
int secondvalue;
System.out.print("Enter the first value:");
firstvalue= sc.nextInt();
System.out.print("Enter the Second value:");
secondvalue=sc.nextInt();
int result = firstvalue - secondvalue ;
System.out.println("the result is:" + result);
}
}
#include<stdio.h>
#include<conio.h>
int main()
{
int x,y,z;
x=17;
y=6;
z=x-y;
printf(" the result is: %d ", z);
// %d is use of integer type variables//
return 0;
}
USING JAVA
public static void main(String[] args)
{
int firstvalue = 17;
int secondvalue = 6;
int result = firstvalue - secondvalue ;
System.out.println("the result is: " + result);
}
..........................................................................................................
in both java and c the output will be
the result is: 11
...........................................................................................................
IF WE WANT THE USER TO INPUT THE NUMBERS:
USING C
#include<stdio.h>
#include<conio.h>
int main()
{
int x,y,z;
printf("enter the first value:");
scanf("%d", &x);
printf("Enter the second value:");
scanf("%d", &y);
z=x-y;
printf(" the result is: %d ", z);
// %d is use of integer type variables//
return 0;
}
USING JAVA
import java.util.Scanner;
{
static Scanner sc= new Scanner(System.in);
public static void main(String[] args)
{
int firstvalue;
int secondvalue;
System.out.print("Enter the first value:");
firstvalue= sc.nextInt();
System.out.print("Enter the Second value:");
secondvalue=sc.nextInt();
int result = firstvalue - secondvalue ;
System.out.println("the result is:" + result);
}
}
How to add two numbers using C and java
2:15 AM
No comments
USING C
#include<stdio.h>
#include<conio.h>
int main()
{
int x,y,sum;
x=5;
y=6;
sum=x+y;
printf(" the summation is: %d ", sum);
// %d is use of integer type variables//
return 0;
}
USING JAVA
public static void main(String[] args)
{
int firstvalue = 5;
int secondvalue = 6;
int sum = firstvalue + secondvalue ;
System.out.println(" the summation is: " + sum);
}
..........................................................................................................
in both java and c the output will be
the summation is: 11
...........................................................................................................
IF WE WANT THE USER TO INPUT THE NUMBERS:
USING C
#include<stdio.h>
#include<conio.h>
int main()
{
int x,y,sum;
printf("enter the first value:");
scanf("%d", &x);
printf("Enter the second value:");
scanf("%d", &y);
sum=x+y;
printf(" the summation is: %d ", sum);
// %d is use of integer type variables//
return 0;
}
USING JAVA
import java.util.Scanner;
{
static Scanner sc= new Scanner(System.in);
public static void main(String[] args)
{
int firstvalue;
int secondvalue;
System.out.print("Enter the first value:");
firstvalue= sc.nextInt();
System.out.print("Enter the Second value:");
secondvalue=sc.nextInt();
int sum = firstvalue + secondvalue ;
System.out.println("the summation is:" + sum);
}
}
How to print a line using C, java
2:08 AM
No comments
USING C
#include<stdio.h>
#include<conio.h>
int main()
{
printf("hi !! how are you");
//printf is use to print something we want//
return 0;
}
USING JAVA
public static void main(String[] args)
{
System.out.println("hi!! how are you");
}
......................................................................................................
in both java and c the output will be
hi!! how are you
.......................................................................................................
Subscribe to:
Comments (Atom)
















