Showing posts with label Get Random Column x position using C Program. Show all posts
Showing posts with label Get Random Column x position using C Program. Show all posts

Saturday, December 12, 2015

Get Random Column x position using C Program

Program #26

Description:
Get a random X (Column) position using C Program.

#include<stdio.h>
#include<stdlib.h>
#include<dos.h>
void main(){
  /* Local variable Declaration */
  int randVal;
 
  /* Clear the Screen */
  clrscr();

  for (;!kbhit();){

    /* get random for Column */
    randVal = ( rand() % 100 );
   
 /* randVal range from 0 to 99,
 but we need value range from 1 to 80
 because of COLUMN position range from 1 to 80
 */
    if (randVal >= 1 && randVal <= 80){
      printf("%d\t", randVal%100);
     
   /* Add some delay to see the Random number in the Output screen */
   delay(25);
    }
  }

  getch();
}


Popular Posts