๐•ป๐–—๐–Ž๐–“๐–™๐–‹() && ๐•พ๐–ˆ๐–†๐–“๐–‹()__In _C_☠️

:- printf() and scanf() in C__.

:- The printf() and scanf() functions are used for input and output in C language. Both functions are inbuilt library functions, defined in stdio.h (header file).

printf() function__๐Ÿ‘‡๐Ÿป

:- The printf() function is used for output. It prints the given statement to the console.The syntax of printf() function is given below:-๐Ÿ‘‡๐Ÿป

printf("format string",argument_list)

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

scanf() function

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

  1. scanf("format string",argument_list);  

Program to print cube of given number

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

  1. #include<stdio.h>    
  2. int main(){    
  3. int number;    
  4. printf("enter a number:");    
  5. scanf("%d",&number);    
  6. printf("cube of number is:%d ",number*number*number);    
  7. return 0;  
  8. }    
Output....
:-  The scanf("%d",&number) statement reads integer number from the console and stores the given value in number variable.

The printf("cube of number is:%d ",number*number*number) statement prints the cube of number on the console.

Program to print sum of 2 numbers

:- Let's see a simple example of input and output in C language that prints addition of 2 numbers._๐Ÿ‘‡๐Ÿป

  1. #include<stdio.h>    
  2. int main(){    
  3. int x=0,y=0,result=0;  
  4.   
  5. printf("enter first number:");  
  6. scanf("%d",&x);  
  7. printf("enter second number:");  
  8. scanf("%d",&y);  
  9.   
  10. result=x+y;  
  11. printf("sum of 2 numbers:%d ",result);  
  12.   
  13. return 0;  
  14. }    
Output...

Comments

Popular posts from this blog

Splunk Command's/Queries & Basic Structure/Components &More...

Information Security๐Ÿ‘ฝ