Something in C language

Someone ask me “What print(“%d”,nr);  means ? And somewhere I saw exactly the same sequence but with printf. Can you enlighten me ?”

Surely, I can explain you. Let’s take step by step.

printf – the function for display “nr”  ON SCREEN

%d – a integer variable

nr – the variable which will display ON SCREEN

;   –   at the end of each instruction you must  ;

You saw that I laid emphasis on the fact that displays on-screen. Why ? Because the function printf (not print) is the same function, but printf will display the variable “nr” in a file.

The program run and display the value must display only if you declared correctly.

1) At beginning of the program you must declared the variable like this :

int nr;

2) The variable’s value must be read or you must attribute a value at the variable

scanf(“%d”,&nr);

nr=33;   (33 is only an example)

Don’t forget ! ! ! At reading you must put & ,  but when you display the variable you don’t must put this. If you don’t make like this, the program will return an error.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s