RSS2.0

Looking Something??



[C Programming Language] Standard Function in C Programming Language

Saturday, February 16, 2008

C Programming Language Standard Function

Functions which is often used in C Programming Language :

a. printf

a function in stdio.h library which is used to show string and also placeholders to screen.

b. puts

a function used to show a string to screen when the placeholders isn’t used.

c. scanf

a function which is used to store data whose type is represented by a placeholder in string format to variable memory address which has been decided.

d. getch

a function which is used to read data whose type is character without key ENTER pressed and it won’t be showed. This function is usually used to show output on the screen until key ENTER pressed.

e. getche

a function which is used to read data whose type is character without key ENTER pressed and the character will be showed on the screen.

f. getchar

a function which is used to read data whose type is character, the character will be showed on screen and must be finished with key ENTER pressed.

g. clrscr

a function which is used to clear screen and move the cursor back to the upper left corner.

h. %3d dan %-3d

int x=1;

%3d will show : _ _ 1 - - > it still give 2 space

%-3d will show : 1 - - > empty space will be deleted.



Function Random and Randomize in Dev C++ :

1. Randomize :

To make randomize in order to produce a different random number every time the program running.

Syntax : srand ((unsigned)time(NULL));

2. Random(int num) :

To get a random number between 0 – (num – 1).

Syntax : int x = rand( )% (int num);

For example :

#include

#include

#include //definition of srand, rand

#include //definition of time

int main

{

int n,

x;

printf(“Enter the value of maximum random number : “);

scanf(“%d”,&n);

srand((unsigned)time(NULL));

x = rand()%100;

printf(“Random Number : %d\n”,x);

getch();

}

0 comments: