In C, we use functions from the stdio.h library to take input from the user and display output on the screen.
π Key Functions: printf() for output and scanf() for input.
printf()The printf() function is used to display text and variable values.
#include <stdio.h>
int main() {
printf("Welcome to C Programming!");
return 0;
}
scanf()The scanf() function is used to take input from the user.
#include <stdio.h>
int main() {
int age;
printf("Enter your age: ");
scanf("%d", &age);
printf("You are %d years old.", age);
return 0;
}
%d β for int%f β for float%c β for char%s β for strings& (address-of operator) in scanf() for variables.
& in scanf()Help others discover Technorank Learning by sharing your honest experience.
Your support inspires us to keep building!