SETHA SITE INFORMATION

  • Increase font size
  • Default font size
  • Decrease font size
SETHA SITE INFORMATION

How to Clear Screen in C++?

E-mail Print PDF
This article shows C++ code to clear screen.
  • Use header file: #include<stdlib.h>
  • Use function: system("cls")
Example:
#include<iostream>
#include<stdlib.h>

using namespace std;

int main()
{
    cout<<"Hello world!";
    system("cls");
    cout<<"Hi World!";
    return 0;
}

 

How to Create Popup Menu in Visual Basic .Net 2008?

E-mail Print PDF

This article attaches with a video clip which shows you how to create popup menu in Visual Basic .Net. Popup menu is the menu that can appear when we do right-click on mouse pointer.

Download Sample Here
 

Pascal Triangle in Visual Basic 2008

E-mail Print PDF
The code below produce pascal triangle using Visual Basic 2008 programming language. This sample allows user to enter value of n.
Public Class Form1
    Private Function Factoriel(ByVal n As Integer) As Long
        If n = 0 Then
            Return 1
        Else
            Return n * Factoriel(n - 1)
        End If
    End Function

    Private Sub btnPascal_Click(ByVal sender As System.Object, _
                                ByVal e As System.EventArgs) _
                                Handles btnPascal.Click
        Me.Refresh()
        Dim g As Graphics = Me.CreateGraphics
        Dim w As Integer = Me.Width
        Dim x As Long
        For i As Integer = 0 To Me.txtN.Text
            For j As Integer = 0 To i
                x = Factoriel(i) / (Factoriel(j) * Factoriel(i - j))
                g.DrawString(x, New Font("Arial", 10, FontStyle.Regular), _
                             Brushes.Black, w / 2 - 20 * i + 40 * j, i * 20)
            Next
        Next
    End Sub
End Class
Download Source Code Here
 

Pascal Triangle in Turbo C++

E-mail Print PDF
The code below is written in Turbo C++ to produces a pascal triangle.
#include<iostream.h>
#include<conio.h>

double fact(int n)
{
	if(n==0) return 1;
	else return n*fact(n-1);
}

void main()
{
	clrscr();
	for(int i=0; i<=10;i++)
	{
		for(int j=0; j<=i; j++)
		{
			gotoxy(40-2*i+4*j, 2*i+1);
			cout<<fact(i)/(fact(j)*fact(i-j));
		}
	}
	getch();
}
 

Create Simple English Typing in Turbo C++

E-mail Print PDF

This article shows you how to create a very simple English Typing in C++ programming with Turbo C++ IDE. In this sample, you will see the uses of gotoxy and textcolor for setting cursor position and coloring text respectively.

#include<stdio.h>
#include<conio.h>
#include<string.h>
#include<stdlib.h>
#include<dos.h>

//create simple typing
void main()
{
	clrscr(); //clear screen
	//suppose there are two lesson
	char *lesson[]={"asdf jkl; fdsa ;lkj",	//lesson 1
			"asfg ;khg ghfj dksl"}; //lesson 2
	int numLes=0,i=0;
	char ch;
	gotoxy(1,20);
	cprintf("Press  to exit.");
	while(1){
	    textcolor(7);
	    gotoxy(10,12);
	    cprintf("%s",lesson[numLes]);
	    gotoxy(1,4);
	    cprintf("Lesson: %d",numLes+1);
	    textcolor(14);
	    gotoxy(10+i,12);
	    cprintf("%c",lesson[numLes][i]);
	    //get key press code
	    ch=getch();
	    if(ch==27) exit(1); //press ESC
	    else
	    {
		if(ch==lesson[numLes][i]) i+=1; //type correct
		else
		{  //type incorrect
			sound(500); //make beep sound
			delay(100);
			nosound();
		}
		if(lesson[numLes][i]=='\0')
		{ //end of string
			i=0;
			numLes=(numLes==1)?0:1; //switch lesson 1-2-1
		}
	    }
	}
}
Download Source Code Here
 


Page 3 of 19