Skip to main content

Posts

Showing posts from October, 2011

Sample: Calculation Factorial by Recursive Method

#include<stdio.h> int fact(int s) {     int x,y;     if(s==0)     {         return(1);     }else         {             x=s-1;             y=fact(x);             return(s*y);         }     } int main() {     int i;     printf("\nEnter No");     scanf("%d",&i);     printf("\nResult:: %d",fact(i)); }

Binary Search Operation With the use of Recursive Function

#include<stdio.h> #define MAX 5 int a[MAX]; insert() {     int i;     for(i=0;i<=MAX;i++)     {         printf("\nEnter No :: ");         scanf("%d",&a[i]);     } } sort() {     int i,j,temp;     for(i=0;i<=MAX;i++)     {         for(j=i;j<=MAX;j++)         {             if(a[i]>a[j])             {                 temp=a[j];                 a[j]=a[i];                 a[i]=temp;             }         } ...

Sample: A Java Applet Program to Calculate Summation of two numbers

import java.awt.*; import java.applet.*; public class user extends Applet {     TextField t1,t2; // Declaring Object variables     public void init() // Initializing Objects     {         t1=new TextField(10);         t2=new TextField(10);         add(t1);         add(t2);         t1.setText("0.00");         t2.setText("0.00");     }     public void paint(Graphics g) // Drawing Objects On The Java Form     {         int x=0,y=0,z=0;         String s1,s2,s;         g.drawString("Input A number in Each Box",10,50);         try         {         ...

Example of Reversed Link List Operation in C

#include<stdio.h> #include<malloc.h> typedef struct list { int data; struct list *next; }node; node *START=NULL; insert() { int i;     node *tmp,*q;     tmp=(node*)malloc(sizeof(node)); printf("\nEnter Element :: "); scanf("%d",&i);     tmp->next=NULL;     tmp->data=i;     if(START==NULL)     {         START=tmp;     }else         {             q=START;             while(q->next!=NULL)             {                 q=q->next;             }             q->next=tmp;         } } display() { node *q; if(START==NULL) { printf("\nList Is Empty"); }else{ q=START; while(q!=NULL) { print...

Sample : String Reverse In Java

import java.io.*; class test {     public static void main(String args[])     {         DataInputStream in=new DataInputStream(System.in);         try         {             String text;             System.out.println("\nEnter The Text");             text=in.readLine();             System.out.println("\nIn Reverse Order::\n");             for(int i=text.length()-1;i>=0;i--)             {                 System.out.print(text.charAt(i));             }          ...

Sample: Dual Directional Linked List

#include<stdio.h> #include<malloc.h> typedef struct list {     int data;     struct list *lnext;     struct list *rnext; }node; node *START=NULL; insert() {     int i,f;     node *tmp,*q;     tmp=(node*)malloc(sizeof(node));     printf("Enter a value");     scanf("%d",&i);     tmp->data=i;     if(START==NULL)     {         START=tmp;     }else     {         printf("Enter SIDE 1. Right 2. Left");         scanf("%d",&f);         if(f==1)         {             q=START;             while(q->rnext!=NULL)       ...

Internet and Network Connection in Linux System

1. LAN (Wired) 2. Wireless 3. Mobile Broadband +-+-+-+-+-+-+-+-+-+-+-+-+-+- 1. Wired (LAN) +-+-+-+-+-+-+-+-+-+-+-+-+-+-     Manually entering your network settings:     If you don't have DHCP on your network then you can configure a static         connection. You will need to enter the network settings yourself, so         check with your network administrator or look at your router's         settings to find out which details to use.    1.Right click the Network Manager icon in the system notification area and click Edit Connections.       2.Click the Wired tab, select the connection and click Edit.           3.Click the IPv4 Settings tab and choose Manual from the Method drop down list.         4.Click Add and enter your IP address and...

Basic Link List Operations

//Basic Link List Operation #include<stdio.h> #include<malloc.h> typedef struct list {     int data;     struct list *next; }node; int count=0; node *START=NULL; insert(int i) {     node *tmp,*q;     tmp=(node*)malloc(sizeof(node));     tmp->next=NULL;     tmp->data=i;     if(START==NULL)     {         START=tmp;         count++;     }else         {             q=START;             while(q->next!=NULL)             {                 q=q->next;             }          ...

Circular Queue in C language

//Circular Queue in C language #include<stdio.h> #define MAX 5 int queue[MAX]; int front=-1; int rear=-1; insert() {     int i;     if((rear==MAX-1 && front==0) || (front==rear+1))     {         printf("\nQueue is FUll");     }     else     {         printf("\nEnter an element:: ");         scanf("%d",&i);                 if(front==-1)         {             front=0;         }         if(rear==MAX-1)         {             rear=0;         }else         {   ...

Queue in C Language

//Simple Queue Implementation In C language #include<stdio.h> #define MAX 5 int front=-1; int rear=-1; int queue[MAX]; insert() {     int i;     if(rear==(MAX-1))     {         printf("\nQueue Overflowed!");     }else         {             printf("\nEnter A Value::");             scanf("%d",&i);             queue[++rear]=i;             if(front==-1)             {                 front=0;             }         } } delete() {     int i;     if(rear==-1)     { ...

Basic Stack Operation In C Language

// 1. BASIC STACK OPERATION OVER 1D ARRAY #include<stdio.h> #include<conio.h> #define MAX 4 int top=-1; int stack[MAX]; void push() { int i; printf("\nEnter A Number To Store it Into Current Stack:: "); scanf("%d",&i); if(top==MAX) { printf("\nSorry Stack is FULL"); }else { stack[++top]=i; printf("\nNumber Added!!!"); } } void pop() { if(top==-1) { printf("\nStack is empty!"); }else{ printf("\nTOP value is :: %d",stack[top--]); printf("\nOne Value Popped"); } } void main() { int ch,f=0; clrscr(); while(f<=1) { printf("\n1. ADD VALUE\n2. POP VALUE\n3. EXIT"); scanf("%d",&ch); switch(ch) { case 1: push(); getch(); break; case 2: pop(); getch(); break; case 3: exit(); default: printf("\nWrong Input"); } } } //2. BASIC STACK O...

Using the mod() function with negative numbers

Using the mod() function with negative numbers     There are different ways of thinking about remainders when you deal with negative numbers, and he is probably confusing two of them. The mod function is defined as the amount by which a number exceeds the largest integer multiple of the divisor that is not greater than that number. In this case, -340 lies between -360 and -300, so -360 is the greatest multiple LESS than -340; we subtract 60 * -6 = -360 from -340 and get 20:     -420 -360 -300 -240 -180 -120 -60 0 60 120 180 240 300 360 --+----+----+----+----+----+----+----+----+----+----+----+----+----+-- | | | | -360| |-340 300| |340 |=| |==| 20 40 Working with a positive number like 340, the multiple we subtrac...

A simple java threading example...

class A extends Thread {         public void run()         {                 for(int i=1;i<=5;i++)                 {                         if (i==1) yield();                           System.out.println("\tFrom Thread A : i = "+i);                 }                 System.out.println("\nExit from A");         } } class B extends Thread {         public void run()         {                 for(int j=1;j<=5;j++)                 {                      ...

Searching BOOLEAN on the INTERNET

A Primer in Boolean Logic The Internet is a vast computer database. As such, its contents must be searched according to the rules of computer database searching. Much database searching is based on the principles of Boolean logic. Boolean logic refers to the logical relationship among search terms, and is named for the British-born Irish mathematician George Boole. On Internet search engines, the options for constructing logical relationships among search terms often modify the traditional practice of Boolean searching. This will be covered in the section below, Boolean Searching on the Internet. Boolean logic consists of three logical operators: OR AND NOT Each operator can be visually described by using Venn diagrams, as shown below. OR logic college OR university Question: I would like information about college. In this search, we will retrieve records in which AT LEAST ONE of the search terms is present. We are searching on the term...