PRINTF SCANF EXAMPLE IN C LANGUAGE

A simple example to get input and display output in c language Syntax:
printf(" "); Anything inside double quotes "" displays message on console.
scanf(""); used to get input from user.

Example:

#include<stdio.h>
int main()
{
// First we declare variables for more details view "declaring c variables"
int number,
char character;
float decimal;
//Then we ask user to enter values
printf("\n Enter any integer value");// Displays the message
scanf("%d",&number);// Gets input from user
printf("\n Enter any decimal value");
scanf("%f",&decimal);
printf("\n Enter any character");
scanf("%c%",&character);
printf("\n Entered values are");
printf('\n Integer %d',integer);
printf('\n Decimal value: %f ',decimal);
printf('\n'Character :%c",character);
}

Output:
Enter any number:
123
Enter any decimal:
1.23
Enter any character:
a
Entered values are:
Integer: 123
Decimal:1.23
Character: a

Description:
In this example we are first displaying a message asking user to enter certain values of different types.
Then user enters values and values are displayed accordingly.
Two predefined functions "printf() and scanf()" are used.
printf() - To display data on screen.
scanf() - To get input from keyboard.

Description In marathi / मराठीत वर्णन

या उधरणात आपण console वर वेग - वेगळ्या प्रकारचे शब्द किवा अंक (data) लिहिलेला आहे.
शब्द किवा अंक कसा keyboard कडून घ्याचा आणि screen वर दाखवायचा हे या उधारणात गितला आहे.
या उधारणात दोन functions "printf() आणि स्कॅन्फ()" वापरले आहे.
printf() - Screen वर काही शब्द किवा अंक लिहिण्या साठी.
scanf() - Keyboard वरून शब्द किवा अंक घेण्य साठी.

Comments

Popular Posts