Q14: Describe scanf() and printf() statement in C language. OR Explain printf() and scanf() with example. OR Write the syntax of printf() and scanf() function, OR Explain formatted output concept with examples. OR Explain scanf() and formatted printf() with suitable examples. Explain unformatted function with syntax and example.

 

A14: scanf() and printf() are two commonly used functions for input and output operations. They are part of the standard input/output library (stdio.h).

 

printf() Function:

printf() is used for formatted output in C. It allows us to display data on the screen.

Syntax of printf(): printf(format_string, argument1, argument2, ...);

e.g. int age = 25; printf("My age is %d years.\n", age);

Output:

My age is 25 years.

 

scanf() Function:

scanf() is used for formatted input in C. It allows us to read data from the standard input.

Syntax of scanf(): scanf(format_string, &variable1, &variable2, ...);

e.g. int age; printf("Enter your age: "); scanf("%d", &age);

Post a Comment

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