Basic Input

Basic input

Read user input and print to output.

Write a statement that reads an integer into userNum, and a second statement that prints userNum followed by a newline.
Hint — Replace the ?s in the following code:

?("%d", &userNum);
printf("%d\n", ? );
#include <stdio.h>

int main(void) {
 int userNum = 0;

scanf("%d", &userNum);
 printf("%d\n", userNum );

return 0;
 }

 

Read multiple user inputs.

 Write two statements to get input values into birthMonth and birthYear. Then write a statement to output the month, a slash, and the year. End with newline.
#include <stdio.h>

int main(void) {
 int birthMonth;
 int birthYear;

scanf("%d", &birthMonth);
 scanf("%d", &birthYear);
 printf("%d/%d\n", birthMonth, birthYear);

return 0;
}