Skip to main content

Posts

Showing posts from August, 2017

C++ Program to calculate the volume of cube,cylinder and rectangle using function overloading.

#include<iostream.h> #include<conio.h> int volume(int); double vlume(double,int); long volume(long,int,int); int main() { clrscr(); cout<<"Volume of a Cube:"<<volume(11)<<endl; cout<<"Volume of a Cylinder:"<<volume(3.2,5)<<endl; cout<<"Volume of Rectangle:"<<volume(185,15,5)<<endl; getch(); return 0; } int volume(int s); { return(s*s*s); } double volume(double r,int h) { return(3.14285*r*r*h); } long volume(long l,int b,int h){ return(l*b*h); } Output: Volume of Cube:1331 Volume of Cylinder:161.033728 Volume of Rectangle:13875

Java program to find Odd or Even Number

import java.util.Scanner; class oddOrEven { public static void main() { Scanner sc=new Scanner(System.in); int n; System.out.println("Enter a Number:"); n=sc.nextInt(); if(n%2==0) { System.out.prntln("Number is even"); } else { System.out.println("Number is Odd"); } } Output: Enter a Number:  4 Number is even

Java Program to print Multiplication Table

import java.util.Scanner; class multi {  public static void main(String args[]) { Scanner sc=new Scanner(System.in); int n,i; System.out.println("Enter a Number:"); n=sc.nextInt(); for(i=1;i<=10;i++) {   System.out.println(n+" * "+i+" = "+(n*i)); } }} Output: Enter a Number: 5 5 * 1 = 5 5 * 2 = 10 5 * 3 = 15 5 * 4 = 20 5 * 5 = 25 5 * 6 = 30 5 * 7 = 35 5 * 8 = 40 5 * 9 = 45 5 * 10 = 50

Java Program to find the largest of Three Numbers

import java.util.Scanner; class large {    public static void main(String args[]) {     Scanner sc=new Scanner(System.in);     int a,b,c;     System.out.println("Enter the Three values:");     a=sc.nextInt();     b=sc.nextInt();     c=sc.nextInt();     if(a>b && a>c)     System.out.println("First Integer is greater!");    else if(b>a && b>c)     System.out.println("Second Integer is greater!");    else if(c>a && c>b)    System.out.println("Third Integer is greater!");     else     System.out.println("Entered integers are not distinct!"); }} The Scanner class is imported to enable the reading from the keyboard. We use three Integer variables a,b and c. Next line we accept values from the user. We check whether a is greater than b and a is greater than c? if it is true then a is greater. Else if b is greater than a and b is greater than c? if it is true then b is greater. E

The Man Killing Game: Blue Whale Game

Hi Folks,  Today am gonna share with you some information about the game that went too horrifying. Last day I saw a news, titled a 14-year-old Mumbai, Indian boy died by playing a game.  So, I was wondering how could it is even possible for a game to kill a man, Then I searched over Google to find some mysteries about the game.  The name of the game was "Blue Whale" since its name can mean a game about blue whales!! Guys, you are wrong!. Blue whale game is a Virtual game. It cannot be downloaded like other games you download from playstore or apple store. You cannot find the link to download this game by just searching over the internet. The link of this game is shared so secretly using private chat rooms and forums. This game was developed by a 21-year-old Russian guy named "Phillip Budikin" , he says that he developed this game in order to remove all the wastes from the world. It simply means: He wants everyone to die. So, this game is a death

C++ Program to list the Fibonacci Series

#include<iostream.h> using namespace std; int main() { int f1=0,f2=1,f3,i,n; cout<<Enter the length of the Series:"<<endl; cin>>n; cout<<"Following are the Fibonacci numbers upto nth:"<<endl; cout<<f1<<endl<<f2; for(i=2;i<n;i++) { f3=f1+f2; cout<<f3<<endl; f3=f1; f1=f2; f2=f3; } return 0; } The above program will print the Fibonacci series till to the nth number. Before getting into the logic of the program we must be knowing what actually is Fibonacci numbers? So, let me say these numbers are created by summing up the left two values. It starts from 0. The first two values will be 0 and 1, The addition of these two numbers will get us the third number that is 1, Now, we consider 1 and 1 to get the next digit. So, it is 2. 0 1 1 2 3 5 8 13 21 34... How we got these numbers? add 0+1=1, then 1+1=2, then,1+2=3,...it continues. Output: Enter the

C++ program to Swap two values without using a Third Variable

#include<iostream.h> using namespace std; int main() { int v1,v2; cout<<"Enter the two Values:"<<endl; cin>>v1>>v2; cout<<"Values Before Swapping:"<<v1<<" and "<<v2<<endl;  //Program Logic v1=v1+v2; v2=v1-v2; v1=v1-v2; cout<<"Values After Swapping:"<<v1<<" and "<<v2<<endl; return 0; } In this program, we require only two variables to store the values. Here we name the variables as v1 and v2, The logic is very simple! For ex: we assign v1=20 and v2=30  Now, we assign v1=v1+v2; so v1 will contain the sum of v1 and v2.i.e., 20+30=50 Through the second step, we will be assigning v2=v1-v2; i.e., 50-30=20, Next, to the final step of the logic, we assign v1=v1-v2; i.e., 50-20=30, So at final, the Variable v1 will contain value 30 and v2 will contain value 20. v1=20; v2=30 v1=v1+v2; //v1=20+30 ;Therefore, v1=50; v2=v1-v2; //v2=

C program to swap to values using the Third Variable

#include<stdio.h> /*#include<conio.h>*/ int main() { int a,b,c; /*Accept the values for swapping*/ printf("Enter the two values:"); scanf("%d%d",&a,&b); /*Print the values before swapping*/ printf("Values before swapping:%d and %d",a,b); /*Logic for Swapping*/ c=a;       /*Here the value of a is stored in variable c*/ a=b;      /*Now the value of b is assigned to variable a*/ b=c;     /*Finally the value stored in c is assigned to b*/ /* Now, lets print the swapped values*/ printf("Values after swapping:%d and %d",a,b); return 0; } The above Program is using three variables a,b and c. The two values that we enter will be stored in the variables a and b correspondingly. We use a third variable c as the temporary variable to store data temporarily or for some sort of time. Now when c=a is executed the value in a is stored temporarily in c, so that the value will not be lost. Then we execute the next line

The Words of Friendship...A beautiful poem written by my friend..

Hi, Folks. Today am going to share with you a song written by my best friend to me regarding our friendship. And she titled it as " The Words Of Friendship..". The silly words of Friendship Gives chilly feelings to the heart But the words spoken and unspoken Sounds like an echo in the heart The words shine like a diamond And if the heart says its blissful happiness The words taste like honey And if the heart says its sweet The words fill tears in your eyes And if the heart says it was the mistake The words fill silence in between And if the heart says it's hurting But the words of  your Friendship Remains even in your Hardship And if the heart says that it's Yours is the best Friendship                                                   -Written By: Blessy Abraham