if else break c program example
if else break c program example What would be output of the program: main( ) { int x = 4, y = 0, z ; while ( x >= 0 ) { if ( x == y ) break ; else printf ( “\n%d %d”, x, y ) ; x– ; y++ ; } } … Read more
C Tutorial
if else break c program example What would be output of the program: main( ) { int x = 4, y = 0, z ; while ( x >= 0 ) { if ( x == y ) break ; else printf ( “\n%d %d”, x, y ) ; x– ; y++ ; } } … Read more
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++ 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 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 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 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
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 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
Bubble Sort : Overview Bubble sort is considered the simplest sorting algorithm. Bubble Sort is used to sort a given set of n elements provided in form of an array with n number of elements. Bubble Sort compares all the element one by one and sort them based on their values. It is known as … Read more
What is algorithm An algorithm is step by step description of the method to solve a problem. It is an effective procedure for solving a problem in a finite number of steps an algorithm to find the factorial of a number How to start writing algorithm : Step by Step solve the problem Problem Description … Read more