C Tutorial
C Tutorial
Chess Game program in C language
Chess Game program in C language #include<stdio.h> #include<conio.h> #include<graphics.h> void blk(int,int); void display(); //enum bool{TRUE,FALSE}; /*void main() //MAIN FUNCTION { display(); getch(); } */ void display() //DISPLAY TO SHOW THE BOARD { int gd=DETECT,gm,i,j,l,m,b; char pattern[]={0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF}; int arrodd[32][2]={ {0,0},{100,0},{200,0},{300,0},{50,50},{150,50} ,{250,50},{350,50},{0,100},{100,100},{200,100},{300,100} ,{50,150},{150,150},{250,150},{350,150},{0,200},{100,200} ,{200,200},{300,200},{50,250},{150,250},{250,250},{350,250}, {0,300},{100,300},{200,300},{300,300},{50,350},{150,350}, {250,350},{350,350} }; int arrevn[33][2]={{50,0},{150,0},{250,0},{350,0},{0,50},{100,50},{200,50}, {300,50},{50,100},{150,100},{250,100},{350,100},{0,150}, {100,150},{200,150},{300,150},{50,200},{150,200},{250,200}, {350,200},{0,250},{100,250},{200,250},{300,250},{50,300}, {150,300},{250,300},{350,300},{0,350},{100,350},{200,350}, {300,350}}; clrscr(); initgraph(&gd,&gm,””); … Read more
Tetris Game in C : Game program in C
Tetris Game in C : Game program in C Let us see the Tetris Game in C #include <graphics.h> #include <stdlib.h> #include <stdio.h> #include <dos.h> #include <conio.h> void swap(int a,int b);void bar1();void bar2(); void bar3(); void bar4(); check0(); check1(); check2(); void del(); void rod1(); void rod2(); void box1();void box2();void tee1();voidtee2(); void tee3();void tee4();check3();void insert(); void … Read more
Egg Game Program in C Langauage
Egg Game Program in C Langauage #include<dos.h> #include<graphics.h> #include<stdio.h> #include<conio.h> #include<process.h> #include<dos.h> #include<stdlib.h> #include<iostream.h> union REGS i,o; main() { int initmouse(); int restrictmouseptr(int,int,int,int); int getmousepos(int *,int *,int *); int showmouseptr(); int gd=DETECT,gm,maxx,maxy,x,y,button; initgraph(&gd,&gm,””); int count=0; maxx=getmaxx(); maxy=getmaxy(); setbkcolor(1); setviewport(0,0,maxx,maxy,1); gotoxy(26,1); if(initmouse()==0) { closegraph(); restorecrtmode(); //to go back to normal graphics mode or deleting viewport. … Read more
Car Racing game in C++
Car Racing game in C++ Here is a Car race game program written in c++ with 5 levels and 3 life. Let us see the c++ program here. #include<iostream.h> #include<conio.h> #include<graphics.h> #include<dos.h> #include<process.h> #include<stdlib.h> void makecar(int x, int y) { rectangle(x+1,y,x+49,y+100); rectangle(x+1,y+25,x+49,y+75); setfillstyle(SOLID_FILL,8); floodfill((x+x+50)/2,(y+y+100)/2,15); } void clear(int x,int y) { setcolor(8); rectangle(x+1,y,x+49,y+100); rectangle(x+1,y+25,x+49,y+75); setfillstyle(SOLID_FILL,8); floodfill((x+x+50)/2,(y+y+100)/2,8); … Read more
Basics of file handling in C language
Basics of file handling in C language There are two types of files, which can be handled through C programming language: Character Oriented File Handling/Text files Binary Oriented File Handling/Binary files For file handling, we use a structure named “FILE” which is declared in stdio.h header file. Some important and most useful file handling functions: … Read more
C program to print Fibonacci series
C program to print Fibonacci series Fibonacci series is a series of number in which each number is the sum of preceding two numbers. for example: 0 1 1 2 3 5 8 13 21 … The next number is found by adding up the two numbers before it as : The 2 is found … Read more
Pyramid Programs in C
Pyramid Programs in C Here is a example of c program to print pyramid structure as below: * * * * * * * * * * * * * * * Let’s start writing pyramid program #include<stdio.h> #define MAX 5 int main() { int i,j; int space=4; /*run loop (parent loop) till number of … Read more
Insertion Sort Algorithm
Overview : Insertion Sort Algorithm Sorting is the process of arranging a list of elements in a particular order (Ascending or Descending). What is Insertion sort In insertion sort algorithm, every iteration moves an element from unsorted portion to sorted portion until all the elements are sorted in the list. Insertion Sort Algorithm sorts array by … Read more
an algorithm to check prime number
An algorithm to check prime number A number that is divisible only by itself and 1, is prime number Example of prime numbers are 2, 3, 5, 7, 11, 13, 17, 19, 23…. etc Algorithm Step 1: Start Step 2: Declare variables n,i,flag. Step 3: Initialize variables flag←1 i←2 Step 4: Read n from user. Step … Read more