pder Lab Web C Programming Lecture4 Input and
$p!der. Lab. Web C Programming Lecture-4 Input and output
What is address of a variable? When ever a variable is created then it is stored in the memory cells and every memory cells has a unique address. This address is called address of a variable. To know the address of a variable we use the ampersand symbol (&) before the variable name. Eg. To know the address of variable a &a This address is managed internally but we can provide the address dynamically.
Input For taking input in the program, we have a built-in function called scanf() function Syntax : scanf(“control string”, addresses of variables); Eg. scanf(“%d”, &num) This statement will take the integer value and stores it in num variable.
Output For showing some output in the console window, we use printf() function. Syntax : printf(“control string”, variables); Eg. printf(“%d”, num) This statement will print the integer value stored in num variable on the console screen.
Control String This is the string which tells about how the data should be taken or how it should be printed. There are different ways to take or give variables of different types of variables. They are used with the percentage symbol (%). Datatypes Control String char %c int %d float %f string %s unsigned integer %u
Thank you!
- Slides: 6