Input & Output
scanf()
The method scanf is used to take input value from user
scanf("%d", variable_name);
Here %d is the format specifier in C, we can use different format like %f, %c etc . Based on what type of data we are declaring.
printf()
Printf function is used for printing the output
printf("Hello Dear");
Here we see various format specifier in C
Character
Input : scanf("%c",&name);
Output : printf("%c", name);
Integer
Input : scanf("%d",&age);
Output : printf("%c", age);
Float
Input : scanf("%f",&percentage);
Output : printf("%f", percentage);
Example
#include <stdio.h> int main() { char name[30]; int age; char grade; printf("Enter the name,age,grade\n"); scanf("%s %d %c", &name, &age, &grade); printf("Hello %s how are you\n",name); printf("Plese check and confirm : - %s, %d, %c",name, age,grade); return 0; }
OutPut
Enter the name,age,grade Vedanth 28 A Hello Vedanth how are you Plese check and confirm : - Vedanth, 28, A