Input and Output is main function of c Language, input is use for scan or get value from user, input faction also know as 'Scanf' and Output is use for to give or provide the value to user, Output function also know as 'Printf'.

printf() and scanf() in c

Input Functions:

1) Scanf(): With the help of this function we can call all types of read. This function should have at least 2 parameters. One is the string which has the conversion specification characters that follow it. other parameter can only be variable name. At least one variable values can be control. At least one variable name should be present if this function is called "Scanf".

 Syntax:-scanf("control string", var1, var2);

2) Getch():  function is used to accept only character type data. Each time getch() function is called, it return the next input character. Without it we can't display our output result.

Output Functions:

1) Printf(): With the help of this function all types of valued can be It works with same as scanf function. But the first parameter can also contain string constants control string). The remaining parameters can be constants, variables or expressions. 

 Syntax:- printf("This is my first programs"); 

2) Putch(): This function is used to output only character type data, the written. Content of a character type variable is displayed. Each time this putch() functions is not necessary to called if it return one output character that represented by the arguments variable. (not used because it required much memory).

Program to Add Two Integers


#include <stdio.h>
int main() {    

    int num1, num2, sum;
    
    printf("Enter two integers values: ");
    scanf("%d %d", &num1, &num2);

    // calculating sum
    sum = num + num2;      
    
    printf("%d + %d = %d", num1, num2, sum);
    return 0;
}

Output:

Enter two integers values: 12
12
12 + 12 = 24

In Above program, asked to user to enter Two integer Values. Values are stored. values are store in variable num1 and num2.

printf("Enter two integers values: ");
scanf("%d %d", &num1, &num2);

after that two number are add using '+' operator and result stored in 'sum' variable.

sum = num1 + num2;