Posts

Showing posts from May 27, 2018

how to make snake game

Image
Program: \\my name is khalid amin #include <stdio.h> #include <time.h> #include <stdlib.h> #include <conio.h> #include<time.h> #include<ctype.h> #include <time.h> #include <windows.h> #include <process.h> #define UP 72 #define DOWN 80 #define LEFT 75 #define RIGHT 77 int length; int bend_no; int len; char key; void record(); void load(); int life; void Delay(long double); void Move(); void Food(); int Score(); void Print(); void gotoxy(int x, int y); void GotoXY(int x,int y); void Bend(); void Boarder(); void Down(); void Left(); void Up(); void Right(); void ExitGame(); int Scoreonly(); struct coordinate{     int x;     int y;     int direction; }; typedef struct coordinate coordinate; coordinate head, bend[500],food,body[30]; int main() {     char key;     Print(); ...

Prime numbers between 2 numbers

Image
Program: #include<stdio.h> #include<conio.h> void main(void) { int n1,n2,i,flage; printf("\n Enter a number:"); scanf("%d",&n1); printf("\n Enter a number:"); scanf("%d",&n2); printf("\nPrime number between %d and %d is:",n1,n2); for(i=1+1;i<n2;++i) { flage=check_prime(i); if(flage==0) printf(" %d ",i); } } int check_prime(int num) { int j,flage=0; for(j=2;j<=num/2;++j) if(num%j==0) { flage=1; break; } return flage; } Output:  Enter a number:2  Enter a number:5 Prime number between %d and %d is:2  3  5

How to made diamond

Image
Program #include<stdio.h> #include<conio.h> void main(void) {          int n,c,k,space=1;          printf("\nEnter a number of rows:");          scanf("%d",&n);          space=n-1;          for(k=1;k<=n;k++)          {                  for(c=1;c<=space;c++)                  printf(" ");                  space--;                  for(c=1;c<=2*k-1;c++)     ...

how to made pyramid

Image
Program: #include<stdio.h> #include<conio.h> void main(void) { int row,c,n,temp; printf("\nEnter a no of rows of pyramid of star:"); scanf("%d",&n); temp=n; for(row=1;row<=n;row++) { for(c=1;c<=temp;c++) printf(" "); temp--; for(c=1;c<=2*row-1;c++) printf("*"); printf("\n"); } Output   Enter a no of rows of pyramid of star:7             *           ***         *****       *******     *********   *********** *************   Note printf(" "); between the inverted comma space is not optional