google.com, pub-8786015629279405, DIRECT, f08c47fec0942fa0 Input and Output Function in C

Input and Output Function in C

0




In C Programming, we need to input or output function to input the value through the user or display the result after computation. so, here we discuss the input or output function provided by the c language/programming.These functions are inbuilt functions that defined in stdio.h (header file).

Output Function/printf():

The printf() function is used for output. It prints the given statement to the console.

The syntax of printf() function is given below:

printf("Statement  string");

OR

printf("format string",argument_list);  

The format string can be %d (integer), %c (character), %s (string), %f (float) etc.


Input Function/scanf():

The scanf() function is used for input. It reads the input data from the console.

scanf("format string",&argument_list);  


Let's see a simple example of c language that gets input from the user and prints the Square of the given number.


#Write a Program to Print Square of a Number

#include <stdio.h>

#include <conio.h>

void main(){

int num;

printf("Enter a value to print Square ");

scanf("%d",&num);

printf("The Square of the Number is = %d",num*num);

}

 

 

Output

Enter a value to print Square 5

The Square of the Number is = 25

 

The scanf("%d",&num) statement reads integer number from the console and stores the given value in number variable.

The printf("The Square of the Number is = %d",num*num); statement prints the Squre of number on the console.

Post a Comment

0 Comments
* Please Don't Spam Here. All the Comments are Reviewed by Admin.

Thank you for your interest 😊

We will back shortly after reviewing...

Thank you for your interest 😊

We will back shortly after reviewing...

Post a Comment (0)

#buttons=(Accept !) #days=(20)

Our website uses cookies to enhance your experience. Learn More
Accept !
To Top