Chap10 (ICS12)
Chap10 (ICS12)
12
(MS Access and C)
One printf can print several lines by using newline escape sequence – ‘\n’
Each time the \n (newline) escape sequence is encountered, output continues at the beginning of the next line.
printf(“Welcome\nto\nC\n”);
Waits for user input, then stores the input value in the memory space that was assigned to n
Getting Multiple same Inputs
printf(“Please enter your height and weight:”);
scanf(“%f%f”, &height, &weight);
Getting Multiple different Inputs
scanf(“%d %d %f”, &n1, &n2, &avg); // will get different types of input
variable It indicates the variable in which the character is stored. The use of variable is optional.
It indicates the variable in which the character is stored. The use of variable is optional.
The above program uses getche() function to input character. The function stores the entered character in
variable c without waiting to press Enter. The printf statement displays the character and its ASCII code on the
screen.
Examples
sizeof(n);
sizeof(10);
sizeof(4.5);
sizeof(“Pakistan”);