| Tutorial ID | 97 |
|---|---|
| Title | Basic Input/Output of C |
In C, two of the most popular input and output function is printf() and scanf(). As in Tutorial1 : Your first C Program, the example output "Hello World" by the function printf(). This tutorial will talk more about their properties. Here's an example code: #include <stdio.h> Sample output What is your name? Printf() The format of printf is: printf("PUT YOUR TEXT HERE!"); or printf("TEXT AND %d %s %c......", variable1, variable2, variable3, etc........); "%" tells the compiler you want to output value of a variable, and the character after "%" indicates what type of variable you want to print. Here's some basic types you may know. %c : char %s : string(array of char) %d : integer %f : float "\" is for printing some special characters, like line break "\n". Scanf() The format of scanf is similar: scanf("%d %s%f", &integer1, string1, &float1); The text inside two quotation marks are exactly the same with printf. However, you need to add "&" to the list of variables, because the compiler needs the "reference" of the variables. "Reference" should be talked in some later tutorials. But all array variables hold their reference, thus do not need "&" before them. | |
| problem_id | title | description | submit | accepted | difficulty |
|---|---|---|---|---|---|
| 1003 | a + b | A + B Problem Given 2 integers a and b, calculate a + b. | 620 | 565 | 231 |
| 1115 | Cashier | Bob is working at a cashier counter, he needs to make hundreds of changes everyday. But he is very laze and does not want to count how ma... | 3 | 0 | 537 |
Facebook