Basic Commands printf in c programming language is useful to display or print characters written into the screen. While the Basic Commands scanf useful to ask for user input.
Examples of programs:
# Include <stdio.h>
# Include <conio.h>
void main ()
{
printf ("Programming Language C Language Learning with visualALPRO.blogspot.com");
}
The above command is useful for displaying "Learn C Programming Language with visualALPRO.blogspot.com" on the console screen. Unfortunately the above program will display the text in just a short time, so our eyes will be difficult to catch his writings, therefore we must add the getch (); at the end of the program. So that the program would be like this:
# Include <stdio.h>
# Include <conio.h>
void main ()
{
printf ("Programming Language C Language Learning with visualALPRO.blogspot.com");
getch ();
}
Instead the command "printf" is used to retrieve input entered by the user via the keyboard.
Examples of programs:
# Include "stdio.h"
# Include "conio.h"
void main ()
{
char name [20];
clrscr ();
printf ("Enter your name:");
scanf ("% s", & name);
printf ("Hello, Your name is% s", name);
getch ();
}
The above command will print "Enter your name" on your computer screen, obtained from the commands printf ("Enter your name:");
then the program prompts you to enter data via keyboard and data you entered will be recorded scanf ("% s", & name);
and displayed back to "Hello, Your name is visualAlpro" (eg, a name that you type is "visualAlpro")
Perhatikkan! Previously we have declared that the variable name is a character data type with a length of 20 characters by the way: char name [20];
Tidak ada komentar:
Posting Komentar