Saturday, 13 May 2017

Snake And Ladder Graphics Program

/* Snake and Ladder Table */
#include<stdio.h>
#include<graphics.h>
#include<conio.h>
void main()
{
int i=0 ,j =0, k= 5;
int gd= DETECT ,gm ;
void ladder1 ();
void ladder2 ();
void snake1 () ;
void snake2 () ;
void snake3 () ;
void numbering () ;
initgraph( &gd ,& gm ,"c: \t c
\b gi" ) ;
for ( i=0 ;i <=360 ;i+= 40 )
for (j =0; j<= 360 ; j+= 40 )
{
setfillstyle( 1,k );
bar
( 50 +j, 30 +i, 90 +j, 70 +i) ;
k += 2;
}
ladder1 () ;
ladder2 () ;
snake1 () ;
snake2 () ;
snake3 () ;
numbering() ;
getch() ;
}
void ladder1 ()
{
int m,n ;
for ( m=0 ;m <=250 ;m+= 250 )
for (n =0; n<= m; n+= 250 )
{
setcolor(8) ;
line
( 53 +m, 57 +n, 55 +m, 55 +n) ;
line
( 53 +m, 57 +n, 133 +m ,137 + n) ;
line
( 55 +m, 55 +n, 135 +m ,135 + n) ;
line
( 133 +m ,137 + n, 135 +m ,135 + n);
setfillstyle(1, 14 );
floodfill(55 + m,58 + n,8 );
line
( 68 +m, 42 +n, 70 +m, 40 +n) ;
line
( 68 +m, 42 +n, 148 +m ,122 + n) ;
line
( 70 +m, 40 +n, 150 +m ,120 + n) ;
line
( 148 +m ,122 + n, 150 +m ,120 + n);
floodfill(70 + m,43 + n,8 );
line
( 65 +m, 65 +n, 78 +m, 52 +n) ;
line
( 68 +m, 68 +n, 81 +m, 55 +n) ;
floodfill(79 + m,54 + n,8 );
line
( 75 +m, 75 +n, 88 +m, 62 +n) ;
line
( 78 +m, 78 +n, 91 +m, 65 +n) ;
floodfill(89 + m,64 + n,8 );
line
( 85 +m, 85 +n, 98 +m, 72 +n) ;
line
( 88 +m, 88 +n, 101 +m ,75 +n );
floodfill(99 + m,74 + n,8 );
line
( 95 +m, 95 +n, 108 +m ,82 +n );
line
( 98 +m, 98 +n, 111 +m ,85 +n );
floodfill
( 109 +m ,84 +n ,8 );
line
( 105 +m ,105 + n, 118 +m ,92 +n );
line
( 108 +m ,108 + n, 121 +m ,95 +n );
floodfill
( 119 +m ,94 +n ,8 );
line
( 115 +m ,115 + n, 128 +m ,102 + n);
line
( 118 +m ,118 + n, 131 +m ,105 + n);
floodfill
( 129 +m ,104 + n, 8);
line
( 125 +m ,125 + n, 138 +m ,112 + n);
line
( 128 +m ,128 + n, 141 +m ,115 + n);
floodfill
( 139 +m ,114 + n, 8);
}
}
void ladder2 ()
{
int p,q =0 ;
for ( p=0 ;p <=180 ;p+= 155 )
{
line(100 + p,330 -
q ,140 + p, 290 -q );
line(100 + p,330 -
q ,102 + p, 332 -q );
line(102 + p,332 -
q ,142 + p, 292 -q );
line(142 + p,292 -
q ,140 + p, 290 -q );
floodfill(141 +p, 292 -
q ,8 );
line(115 + p,345 -
q ,155 + p, 305 -q );
line(115 + p,345 -
q ,117 + p, 347 -q );
line(117 + p,347 -
q ,157 + p, 307 -q );
line(157 + p,307 -
q ,155 + p, 305 -q );
floodfill(155 +p, 307 -
q ,8 );
line(112 + p,322 -
q ,125 + p, 335 -q );
line(114 + p,320 -
q ,127 + p, 333 -q );
floodfill(125 +p, 334 -
q ,8 );
line(122 + p,312 -
q ,135 + p, 325 -q );
line(124 + p,310 -
q ,137 + p, 323 -q );
floodfill(135 +p, 324 -
q ,8 );
line(132 + p,302 -
q ,145 + p, 315 -q );
line(134 + p,300 -
q ,147 + p, 313 -q );
floodfill(145 +p, 314 -
q ,8 );
q+= 95 ;
}
}
void snake1 ()
{
int x,y =0 ,h= 2;
for ( x=0 ;x <=200 ;x+= 125 )
{
arc
( 120 +x ,110 + y, 10, 85 ,60 );
arc
( 258 +x ,85 +y ,190 , 240 ,80 ) ;
arc
( 112 +x ,118 + y, 10, 80 ,60 );
arc
( 250 +x ,93 +y ,190 , 290 ,80 ) ;
arc
( 275 +x ,100 + y, 250 ,270 , 70 );
line
( 250 +x ,170 + y, 250 +x ,165 + y);
line
( 250 +x ,165 + y, 230 +x ,160 + y);
line
( 230 +x ,160 + y, 218 +x ,155 + y);
line
( 130 +x ,50 +y ,115 + x, 47+ y) ;
line
( 121 +x ,59 +y ,106 + x, 52+ y) ;
line
( 106 +x ,52 +y ,114 + x, 48+ y) ;
circle( 114 +x ,52 +y ,1 );
setfillstyle(1, h) ;
floodfill
( 116 +x ,52 +y ,8 );
y+= 230 ;
h+= 8 ;
}
}
void snake2 ()
{
arc ( 130 ,220 , 150 ,180 ,40 );
arc ( 130 ,220 , 180 ,253 ,40 );
arc ( 105 ,328 , 273 ,80 , 70) ;
arc ( 143 ,220 , 150 ,180 ,40 );
arc ( 143 ,215 , 180 ,230 ,40 );
arc ( 112 ,328 , 265 ,50 , 75) ;
arc ( 80, 354 ,45 , 72, 115 );
line(102 ,400 , 104 ,402 ) ;
line(102 ,400 , 107 ,399 ) ;
line(95 , 200 ,110 , 185 );
line(110 ,185 , 109 ,200 ) ;
line(110 ,185 , 111 ,182 ) ;
circle (104 , 198 ,1 );
setfillstyle(1 ,12 );
floodfill( 103 ,199 ,8) ;
}
void snake3 ()
{
arc ( 255 ,118 , 320 ,0 ,170 ) ;
arc ( 265 ,118 , 305 ,0 ,170 ) ;
line(384 ,229 , 361 ,260 ) ;
line(425 ,120 , 429 ,105 ) ;
line(428 ,105 , 435 ,120 ) ;
line(428 ,105 , 429 ,100 ) ;
circle (430 , 115 ,1 );
setfillstyle(1 ,6 );
floodfill( 430 ,117 ,8) ;
}
void numbering()
{
outtextxy( 50 ,393 , "1 2
4 5 6 7 8
10" ) ;
outtextxy( 50 ,353 , "20 19 18 16 15 1 13
11" );
outtextxy( 50 ,313 , "21 22
25 26 29 30" );
outtextxy( 50 ,273 , "40 39 38 37 36 35 34 33 32 31" );
outtextxy( 50 ,233 , "41 43 44 45 47 48
50" );
outtextxy( 50 ,193 , "60 58 57 56 55 53 52 " );
outtextxy( 50 ,153 , "61 62 63 64 66 67 68 69 " );
outtextxy( 50 ,113 , "80 79
76 75 74 73
71" );
outtextxy( 50 ,73 , "81 83 84 85 86 87 89 90" );
outtextxy( 50 ,33 , "100 99 98 97 96 95 94 93 92 91" );
}
/*
Author : vivek kumar (Spyboy);
Date : 5/5/17
*/

If You Want More Source Code Then Visit My Popular Blog bindasscoding.blogspot.com

School Management Programme In C/C++

#include <iostream>
#include <fstream>
#include < string >
#include <conio.h>
#include <windows.h>
using namespace std ;
//Structure defining
//For students
struct student
{
string fname ;//for student first name
string lname ;//for student last name
string Registration ;//for Registration No number
string classes ;//for class info
}studentData ;//Variable of student type
//For teachers
struct teacher
{
string fst_name ; //first name of teacher
string lst_name ; //last nameof teacher
string qualification ;//Qualification of teacher
string exp ;//Experiance of the person
string pay ;//Pay of the Teacher
string subj ;//subject whos he/she teach
string lec ;//Lecture per Week
string addrs ;//Adders of teacher home
string cel_no ;//Phone number
string blod_grp ; //Bool Group
string serves ; //Number of serves in School
}tech[ 50 ];//Variable of teacher type
/////////////////////////////////////////////////// //Main function
void main() {
int i =0 ,j ;//for processing usage
char choice ; //for getting choice
string find ; //for sorting
string srch ;
while( 1) //outer loop
{  system ( "cls" );//Clear screen
//Level 1-Display process
cout<< "\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\" ;
cout<< "\n\n\t\t\tSCHOOL MANAGEMENT PROGRAM\n\n" ;
cout<< "\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\" ;
cout<< "\n\n\t\t\tMAIN SCREEN\n\n" ;
cout<< "Enter your choice: "
<< endl;
cout<< "1.Students information" <<endl;
cout<< "2.Teacher information" <<endl;
cout<< "3.Exit program" <<
endl ;
cin >>choice ;
system ("cls" ); //Clear screen
switch (choice )//First switch
{ case '1' : //Student
{ while( 1) //inner loop-1
{ system ("cls" ); //Clear screen //Level-2 display
cout<< "\t\t\tSTUDENTS INFORMATION AND BIO DATA SECTION\n\n\n" ;
cout<< "Enter your choice: "
<< endl;
cout<< "1.Create new entry\n"
;
cout<< "2.Find and display entry\n" ;
cout<< "3.Jump to main\n" ;
cin >> choice ;
switch ( choice) //Second switch
{
case '1' ://Insert data
{ ofstream f1 ( "student.txt"
,ios ::app );
for ( i= 0; choice!= 'n' ; i++) {
if (( choice== 'y' )||(choice == 'Y' )||(choice =='1' )) {
cout<< "Enter First name: " ;
cin >>studentData .fname;
cout<< "Enter Last name: " ;
cin >>studentData .lname;
cout<< "Enter Registration number: " ;
cin >>studentData .
Registration ;
cout<< "Enter class: " ;
cin >>studentData .classes ; f1 << studentData . fname<< endl
<< studentData .lname << endl<<
studentData . Registration<<
endl <<studentData .classes <<
endl ;
cout<< "Do you want to enterdata: " ;
cout<< "Press Y for Continueand N to Finish:  " ;
cin >>choice ; } } f1 .close (); }
continue;//control back to inner loop -1
case '2' ://Display data
{ ifstream f2 ( "student.txt"
);
cout<< "Enter First name to be displayed: " ;
cin >> find;
cout<< endl;
int notFound = 0 ;
for ( j= 0;( j< i)||(! f2. eof ());
j++) {
getline ( f2, studentData .fname
);
if (studentData . fname== find) {
notFound = 1 ;
cout<< "First Name: " <<
studentData . fname<< endl;
cout<< "Last Name: " <<
studentData . lname<< endl;
getline (f2 ,studentData .
Registration);
cout<< "Registration No number: " << studentData .
Registration <<endl;
getline (f2 ,studentData .
classes );
cout<< "Class: " <<
studentData . classes << endl<<
endl ; }
}
if (notFound == 0 ){
cout<< "No Record Found" <<
endl ; }
f2 .close ();
cout<< "Press any key two times to proceed" ;
getch(); //To hold data on screen
getch(); //To hold data on screen
}
continue;//control back to inner loop -1
case '3' ://Jump to main
{
break; //inner switch breaking
} }
break; //inner loop-1 breaking
}
continue;//Control pass to 1st loop
}
case '2' ://Teachers biodata
{ while( 1) //inner loop-2
{ system ("cls" ); //Clear screen //Level-2 Display process
cout<< "\t\t\tTEACHERS INFORMATION AND BIODATA SECTION\n\n\n" ;
cout<< "Enter your choice: "
<< endl;
cout<< "1.Create new entry\n"
;
cout<< "2.Find and display\n"
;
cout<< "3.Jump to main\n" ;
cin >> choice ;
switch ( choice) //Third switch
{
case '1' ://Insert data
{ ofstream t1 ( "teacher.txt" ,
ios :: app );
for ( i=0 ;choice != 'n' && choice
!= 'N' ;i ++) {  if (( choice == 'y' )||(choice ==
'Y' )||(choice == '1' )) {
cout << "Enter First name: "
;
  cin >> tech[i ].fst_name ;
cout << "Enter Last name:: "
;
  cin >> tech[i ].lst_name ;
cout << "Enter qualification: " ;
cin >> tech[i ].qualification
;
  cout << "Enter experiance(year): " ;
cin >> tech[i ].exp ;
cout << "Enter number of year in this School: " ;
cin >> tech[i ].serves ;
cout << "Enter Subject whos teach: " ;
cin >> tech[i ].subj;
cout << "Enter Lecture(per Week): " ;
cin >> tech[i ].lec ;
cout << "Enter pay: " ;
cin >> tech[i ].pay ;
cout << "Enter Phone Number:" ;
cin >> tech[i ].cel_no ;
cout << "Enter Blood Group: ";
cin >> tech[i ].blod_grp ; t1 <<tech[ i]. fst_name <<endl
<< tech[i ].lst_name << endl << tech[i ]. qualification<<
endl<< tech[i ].exp <<endl
<< tech[i ]. serves<< endl<<
tech [i]. subj<< endl<< tech[i ].
lec
   << endl<< tech[i ].pay <<endl
<< tech[i ].cel_no << endl<<tech
[i ]. blod_grp << endl;
cout << "Do you want to enter data: " ;
cin >> choice ; } //if
}//for loop //for finding through name
system ("cls" );
t1 .close (); }//case 1
continue;//Control pass to inner loop-2
case '2' ://Display data
{ ifstream t2 ( "teacher.txt" );
cout<< "Enter name to be displayed: " ;
cin >> find;
cout<< endl;
int notFound = 0 ;
for ( j= 0;(( j <i )||(!t2 .eof
())); j++) {  getline (t2 ,tech[ j]. fst_name
);  if ( tech[j]. fst_name == find) {
notFound = 1;
cout << "First name: " << tech
[j ]. fst_name << endl;
getline (t2 , tech[j]. lst_name );
cout << "Last name: " <<tech[
j]. lst_name << endl;
getline (t2 , tech[j].
qualification );
cout << "Qualification: " <<
tech [j]. qualification <<endl;
getline (t2 , tech[j]. exp );
cout << "Experience: " << tech
[j ]. exp << endl;
getline (t2 , tech[j]. serves
);
  cout << " number of year in this School: " << tech[ j].
serves << endl;
getline (t2 , tech[j]. subj);
cout << "Subject whos teach:" << tech[j]. subj<< endl;
getline (t2 , tech[j]. lec );
cout << "Enter Lecture(per Week): " << tech[j ]. lec << endl;
getline (t2 , tech[j]. pay );
cout << "pay: " << tech[ j]. pay
<< endl;
getline (t2 , tech[j]. addrs );
cout << "Address: " << tech[ j].addrs << endl;
getline (t2 , tech[j]. cel_no
);
  cout << "Phone Number: " <<
tech [j]. cel_no <<endl;
getline (t2 , tech[j]. blod_grp );
cout << "Bool Group: " << tech
[j ]. blod_grp << endl; } //if }//for loop
t2 .close ();
if (notFound == 0 ){
cout<< "No Record Found" <<
endl ; }
cout<< "Press any key two times to proceed" ;
getch(); //To hold data on screen
getch(); //To hold data on screen
}//case 2
continue;//Control pass to inner loop-2
case '3' ://Jump to main
{
break; //inner switch
}//case 3
}//inner switch
break; //inner while
}//inner loop
continue;//control pass to 1st loop
}//outer case 2
case '3' : {
break; //outer case 3
}//outer case 3
} break; //outer loop
}
}