Thursday, 5 February 2015

Diamond And Star Pattern in C , C++ and Java

Diamond And Star Pattern in C , C++ and Java



Here , comes new tutorial with C,
Same Logic implementation in C, C++, And Java 
Specially for beginners.

Have Fun !!!

Star Pattern 


Code for C

#include<stdio.h>
#include<conio.h>

void main (void) 

{
clrscr();

int i,j,k;

for(i=1; i<=5; i++)

{
    for(j=i;j<=5; j++)
    printf(" ");

    for(k=1; k<=i; k++)
    printf("* ");

    printf("\n");
 }


getch();
}

Code for C++

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

using namespace std;

void main (void) 
{
  clrscr();

   int i,j,k;

 for(i=1; i<=5; i++)
  {
    for(j=i;j<=5; j++)
    cout<<" ";

    for(k=1; k<=i; k++)
    cout<<"* ";

    cout<<endl;
   }


getch();
}

Code for Java


public class MyClass
{
  public static void main(String args[])
  {
      int i,j,k;

      for(i=1; i<=5; i++)
      {
         for(j=i;j<=5; j++)
         System.out.print(" ");

         for(k=1; k<=i; k++)
         System.out.print("* ");

         System.out.println();

      } // loop end
   }   // main end
}  // class end

Diamond Pattern


Code for C

#include<stdio.h>
#include<conio.h>

void main (void) 

{
clrscr();

int i,j,k;

for(i=1; i<=5; i++)

{
    for(j=i;j<=5; j++)
    printf(" ");

    for(k=1; k<=i; k++)
    printf("* ");

    printf("\n");
 }


for(i=5; i>=1; i--)

{
    for(j=i;j<=5; j++)
    printf(" ");

    for(k=1; k<=i; k++)
    printf("* ");

    printf("\n");
 }


getch();
}

Code for C++

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

using namespace std;

void main (void) 
{
  clrscr();

   int i,j,k;

 for(i=1; i<=5; i++)
  {
    for(j=i;j<=5; j++)
    cout<<" ";

    for(k=1; k<=i; k++)
    cout<<"* ";

    cout<<endl;
   }

 for(i=5; i>=1; i--)
  {
    for(j=i;j<=5; j++)
    cout<<" ";

    for(k=1; k<=i; k++)
    cout<<"* ";

    cout<<endl;
   }


getch();
}

Code for Java


public class MyClass
{
  public static void main(String args[])
  {
      int i,j,k;

      for(i=1; i<=5; i++)
      {
         for(j=i;j<=5; j++)
         System.out.print(" ");

         for(k=1; k<=i; k++)
         System.out.print("* ");

         System.out.println();

      } //  outer loop 1 end


      for(i=5; i>=1; i--)
      {
         for(j=i;j<=5; j++)
         System.out.print(" ");

         for(k=1; k<=i; k++)
         System.out.print("* ");

         System.out.println();

      } // outer loop 2 end

   }   // main end
}  // class end


Saturday, 15 November 2014

Create Hidden Secret Folder

Create Hidden Secret Folder




CREATE A FOLDER WITH  "     "  NAME



To create a folder with no name
first create a new folder
then rename it
and press alt key and type 0160 and leave alt key
you will observe that a folder with blank name is created

2nd Option

To create a folder with no name
first create a new folder
then rename it
and press alt key and type 255 and leave alt key
you will observe that a folder with blank name is created


NOW CHANGE THE ICON

To change its icon
right click on folder and goto properties
goto customize tab
click on change icon
now search for a space icon and select it
now click on ok
and apply
you are done



Convert videos without using any converter



 

 Convert videos and audios without using any converter ,,

You just need is VLC player








VLC player is an open source video player that supports most of the video codecs.Most of the people using VLC are unaware that it can also be used to convert files into various video (mp4, webm, ts and ogg ) and audio (mp3,ogg,mp4,aac,cd) formats. VLC  player is available  for  Windows, Mac and Linux operating systems.If you haven’t downloaded it yet  

you can download it from link below :


Trick to Convert Videos Using  VLC  Player


   1. Open your VLC  player
   2. Click on Media and select Convert / Save (Ctrl+R ) option.
   3. In new popup window under the Files tab click on Add button to select files that have to be converted.

Monday, 25 August 2014

C program to implement STACK.

STACK IN C




  Stack is a LIFO data structure 
  LIFO - Last in First Out

  Perform PUSH (insert operation)
  POP (Delete operation) 
  Display (Display stack)

// CODE //


#include <stdio.h>
#include <conio.h>
#define MAXSIZE 5

int st[MAXSIZE];
int top;


/* Function declaration/Prototype*/

void push (void);
int  pop(void);
void display (void);

void main ()
{
int choice;
int option = 1;

clrscr ();

top = -1;

printf ("STACK OPERATION\n");
while (option)
{
printf ("------------------------------------------\n");
printf ("   1 --> PUSH           \n");
printf ("   2 --> POP           \n");
printf ("   3 --> DISPLAY           \n");
printf ("   4 --> EXIT   \n");
printf ("------------------------------------------\n");

printf ("Enter your choice\n");
scanf ("%d", &choice);

switch (choice)
{
case 1: push();
break;
case 2: pop();
break;
case 3: display();
break;
case 4: return;
}

fflush (stdin);
printf ("Do you want to continue(Type 0 or 1)?\n");
scanf ("%d", &option);
}
}

/*Function to add an element to the stack*/
void push ()
{
int num;
if (top == (MAXSIZE - 1))
{
printf ("Stack is Full\n");
return;
}
else
{
printf ("Enter the element to be pushed\n");
scanf ("%d", &num);
top = top + 1;
st[top] = num;
}
return;
}


/*Function to delete an element from the stack*/
int pop ()
{
int num;
if (top == - 1)
{
printf ("Stack is Empty\n");
return (top);
}
else
{
num = st[top];
printf ("poped element is = %d\n", st[top]);
top = top - 1;
}
return(num);
}

/*Function to display the status of the stack*/
void display ()
{
int i;
if (top == -1)
{
printf ("Stack is empty\n");
return;
}
else
{
printf ("\nThe status of the stack is\n");
for (i = top; i >= 0; i--)
{
printf ("%d\n", st[i]);
}
}
printf ("\n");
}



Saturday, 9 August 2014

E-book of Data Structurures and Algorithms in C by Schaum's series(PDF file).

Download the best  Data Structures With C  E-book by just simply clicking HERE.  the Download. button.




 For More of the E-books go  to http://www.techybuz.com/search/label/E-Books   . Thank you All.

Monday, 28 July 2014

C algo to search a word in sentence without string function and pointers method 2



Search a word in sentence or phrase without string function and pointers and indicate its position (Method 2)


No need to explain 

Logic


Code



#include<stdio.h>
#include<conio.h>

void main(void)
{
clrscr();

int a[100];  // to store string or phrase
int b[20];   // to store word or letters to search
int i=0,j=0;

printf("\n Enter sentence or phrase \n");
while((a[i++]=getche())!='\r');
i--;
printf("\n \n Enter word or letters to search for \n");
while((b[j++]=getche())!='\r');
j--;

int r;                 // check the match in sequence..
int match=0;  // indicate that match or not.

for(int x=0; x<i; x++)
{
 r=0;
 for(int y=0; y<j; y++)
 { if(b[y]==a[x+y])
   r++;
 }

 if(r==j)
  {
   printf("\n \n Matched at %d",x+1);
   match=1;
  }
}
if(match==0)
printf("\n Match not found");


getch();
}




Sunday, 27 July 2014

C algo to search a word in sentence without string function and pointers

Search a word in sentence or phrase without string function and pointers and indicate its position




This is a simple algorithm designed to search consecutive letters in a phrase or word in a given sentence and display the position of its first character in given phrase or string, The best part is that in this algorithm neither pointer function is used nor string function is used. It is based on very simple basic logic of arrays.

CODE 

#include<stdio.h>
#include<conio.h>

void main(void)
{
clrscr();

int a[100];  // to store string or phrase
int b[20];   // to store word or letters to search
int c[20];   // to store the position of first character that match

int i=0,j=0;

printf("\n Enter sentence or phrase \n");
while((a[i++]=getche())!='\r');
i--;
printf("\n Enter word or letters to search for \n");
while((b[j++]=getche())!='\r');
j--;



int k=0;   // no. of times 1st char. repeated
              
for (int s=0; s<i ; s++)

// This loop is to check the 1st character that match with phrase or sentence
// and store its position in c[] .

  {
   if(b[0]==a[s])
   c[k++]=s;
  }


int w,fc;
int v=0 ;  // count all matches other than 1st char.
int m=0;  // indicate that word match or not.

for(int x=0; x<k; x++)

// This loop is to check all cases of first char. match.

{
v = 0 ;
fc = c[x];     // store postition of 1st matched char.
w = fc + 1;  // next char. to 1st mathced one.

for(int z=1; z<j; z++)

// This loop is to check the match of letters either consecutive or not.
// i.e match rest of char. of b[].

 {
   if(b[z]==a[w++])
   v++;
 }

// j is the total amount of letters to be matched
// j - 1 to exclude 1st char.

 if(v==(j-1))
 { printf("\n \n Matched all letters at %d postion",fc+1);
  m++; // word match or not.
 }

}

if(m==0)
printf("\n Matched not found");

getch();
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

Enjoy !!!

Must visit an alternate code with different logic + logic's animation to get ..

C-search-word-in-sentence