Search This Blog

Sunday, 13 October 2013

Print Pyramid in java

import java.io.*;
class printPyramidDemo
{
public static void main(String arg[]) throws IOException
     {
 BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
System.out.println("enter the height of pyramid ");
 String s=br.readLine();
int a=Integer.parseInt(s);
 for(int i=0; i<=a; i++)
         {
            for(int k=a; k>=i; k--)
               {
                System.out.print(" ");
                }
           int c=(2*i)-1;
           for(int j=1; j<=c; j++)
               {
                  System.out.print("*");
               }
    System.out.print("\n");
          }
     }
}
output

Addtion Of two Numbers in java

import java.io.*;
class addition
{
    public static void main(String args[]) throws IOException
        {
             float no3;            
             DataInputStream in=new DataInputStream(System.in);
             System.out.println("enter  1st float value for addition:");
             float no1=Float.valueOf(in.readLine()).floatValue();
              System.out.println("enter  2nd float value for addition:");
             float no2=Float.valueOf(in.readLine()).floatValue();
                no3=no1+no2;           
              System.out.println("value of addition is:"+no3);
         }
       

ouput   

Print Numbers By for loop

import java.util.*;
class forloop
{
    public static void main(String args[])
    {
       Scanner in=new Scanner(System.in);
       int n;
       System.out.println("Enter the value:");
       n=in.nextInt();
       System.out.println();
       for(int i=0;i<n;i++)
       {
          System.out.print(i);
        }
    }
}


output 

 

Monday, 16 September 2013

Data Models in SQL

Data Models: Data models represents the arrangements and orgnisation of data in various forms, this helps us to understand how various entities related with each other and helps to implement in computer's memory.

1) Object based model : This represents the data, entities , attributes in pictorial form such as ER-Diagram.

2) Record based model : This represnets the data,entities, attributes in the form records, this manages by a special type of software called database management system(DBMS).

There are three types of record based model:

1)Hierachical Model: In hierachical data model data or entities are represented in the form of tree model. Here one to many relationship exists. One entity can relate with many entity and further each child entity relates with other many entities. There is only one entity that can be called root which is at the top of tree. There can be only one path from the root to any child entity or data.



2) Network model : In network data model data or entities are represented in the form of graph. Here many to many relationship exists. Many entities relate with many related entities. Here each entity can be treated as a node of graph one entity may connects with various entities. There can be multiple paths to visit a node from any other node.

3) Relational model : This model represents the records in the form of relation, a relation is also called a table. A table is collection of various rows and columns. Attributes are called columns in relational model. The total number of columns is called degree of the table/relation. The total number of rows of table is called cardinality. Here all the values of one column belongs to same domain. A domain is a set of rules.



Schema and Instances :
Schema : A schema is the over all defination of a database. This defines various database objects such as tables, columns, relationships, constraints, keys, fuctions, procedures etc. Schema can be created at the time of database creation. Schema is rarely modified. The details of schema is stored in metadata and data dictionary. Metadata is data about data. Schema uses DDL(Data Definition Language).


Instances: Instances are values of database objects. In a database table instances are rows. Instances are always modified by users. This uses DML(Data Manipulation Language).


Sunday, 15 September 2013

Print Pyramid through C++

Pyramid in C++

#include<iostream.h>
#include<conio.h>

main()
{
   int a,b,i,temp;
   cout<<"Enter the level of pyramid:";
   cin>>a;
   temp=a;
   for(i=1;i<=a;i++)
   {
      for(b=1;b<=temp;b++)
      cout<<" ";
      temp--;
      for(b=1;b<=2*i-1;b++)
      cout<<"*";
      cout<<endl;
   }
   getch();
} 

Output 

Binary to Octal Conversion in C++

Digital Conversion From Binary 2 Octal

#include<iostream.h>
#include<conio.h>
#include<string.h>
#include<math.h>

void main()
{
  int ar[10],n,j=0,sum=0,dec,i=0;
  cout<<"Enter the binary value:";
  cin>>n;
  while(n>0)
  {
    sum=sum+n%10*pow(2,j);
    j++;
    n=n/10;
  }
  dec=sum;
  while(dec>0)
  {
    ar[i]=dec%8;
    i++;
    dec=dec/8;
  }
 cout<<"octal value is:";
 for(int k=i-1;k>=0;k--)
 {
    cout<<ar[k];
 }
  getch();
}

Output

Binary to Decimal in C++

Digital Conversion from Binary 2 Decimal

#include<iostream.h>
#include<conio.h>

void main()
{

  char ch;
  do
  {
  int n,rem,sum=0,j=1;
  cout<<"\nEnter the binary value:";
  cin>>n;
  while(n>0)
  {
   rem=n%10;
   sum+=rem*j;
   j*=2;
   n=n/10;
  }
  cout<<"\nDecimal value is:"<<sum;
  cout<<"\nDo u want to continue:";
  cin>>ch;
 }while(ch!='0');
  getch();
}
output

Character Count in a String by C++

Total Characters in a String

#include<iostream.h>
#include<conio.h>
#include<string.h>

void main()
{
  char ch[30];
  int cons=0,alpha=0,digit=0;
  cout<<"Enter a alphanumeric string:";
  cin>>ch;
  int k=strlen(ch);
  for(int i=0;i<k;i++)
  {
     int a=ch[i];
     if(a>=33&&a<=47||a>=58&&a<=64)
     cons++;
     else if(a>=48&&a<=57)
     digit++;
     else
     alpha++;
  }
  cout<<"Given stringis:"<<ch<<endl;
  cout<<"Special character is:"<<cons<<endl;
  cout<<"Digits are:"<<digit<<endl;
  cout<<"characters are:"<<alpha;
  getch();
}
output

Concept of Friend Function in C++

Friend Function of C++

#include<iostream.h>
#include<conio.h>

class fri
{
   int a,b;
   public:
       void input(int x,int y)
       {
          a=x;
          b=y;
        }
        friend int add(fri t)
        {
           int sum;
           sum=(t.a+t.b);
           cout<<"Sum is:"<<sum;
        }
};

void main()
{
   fri r;
   r.input(2,8);
   add(r);
   getch();
}

output

Checking a number is Armstrong or not in C++

Concept of Armstrong in C++

#include<iostream.h>
#include<conio.h>

void main()
{
 int n,rem,sum=0,temp;
 cout<<"Enter a number:";
 cin>>n;
 temp=n;
 while(n>0)
 {
   rem=n%10;
   sum=sum+rem*rem*rem;
   n=n/10;
 }
 if(temp==sum)
   cout<<"Entered number is a armstrong";
 else
 cout<<"Entered number is not armstrong";

 getch();
}

output



Wednesday, 11 September 2013

Arithmatic Operation in C#

Concept of Arithmatic Operator in C#

using System;

class Operators
{
    public static void Main(String[] args)
    {
        int a,b,c,d;
        Console.WriteLine("ARITHMATIC OPERATION\n");
        do{
            Console.WriteLine("Enter 1st no for arithmatic operation\n");
            a=Convert.ToInt32(Console.ReadLine());
            Console.WriteLine("Enter 2nd no for arithmatic operation\n");
            b=Convert.ToInt32(Console.ReadLine());
            Console.WriteLine("Choose from the following for operation:\n");
            Console.WriteLine("1.+\t2.-\n3.*\t4.%\n");
            c=Convert.ToChar(Console.ReadLine());
            switch(c)
            {
                case '1':d=a+b;
                       Console.WriteLine("Sum is:{0}",d);
                       break;
                case '2':d=a-b;
                       Console.WriteLine("difference is:{0}",d);
                       break;      
                case '3':d=a*b;
                       Console.WriteLine("product is:{0}",d);
                       break;      
                case '4':d=a%b;
                       Console.WriteLine("remainder is:{0}",d);
                       break;   
                                                                                       
            }
        }while(c!=5);
        Console.ReadLine();
    }
}

output: 


    

Popular Posts