Today, my college class focused on the fundamentals of C programming. We dove into writing C code, with a specific emphasis on understanding and using format specifiers effectively.
- β Learn the basics of writing C code
- β Understand the importance and usage of format specifiers
- πΉ Execution Of A Program
- πΉ Prototype of
printf - πΉ Printing Different Data Types
- πΉ Precision Control
- πΉ Length Control
- π Introduction to C programming language
- βοΈ Setting up the C environment
- π Writing and executing a simple C program
- π Understanding the structure of a C program
Format specifiers are used in C programming to control the input and output format. They are essential for formatting data in printf and scanf functions. Today, we covered the following format specifiers:
| Format Specifier | Description |
|---|---|
%d |
Integer (int) |
%f |
Floating-point number |
%c |
Character |
%s |
String |
%x |
Hexadecimal representation |
%o |
Octal representation |
%lf |
Double |
%% |
Percent symbol (%) |
%u |
Unsigned decimal integer (unsigned int) |
Hereβs an example of how to use format specifiers in a C program:
#include <stdio.h>
int main()
{
char c = 'a';
int x = -1;
float f = 7.9;
double d = 777.898989;
printf("Formatted output: %c %d %u %o %x %f %lf\n", c, x, x, x, x, f, d);
return 0;
}π This guide enhances the learning experience for C programming with structured insights and examples!