C Programming Basics

C is a compiled programming language built around functions, variables, expressions and statements. A beginner can start with a small main() function, print output with printf(), read input with scanf(), and then move into conditions, loops, arrays and functions.

First C Program Top ↑

#include <stdio.h>

int main(void) {
    printf("Hello, World!\n");
    return 0;
}

Output

Hello, World!

#include <stdio.h> makes the standard input/output declarations available. Program execution begins in main(), and return 0; reports successful completion to the operating environment.

Learn the C Fundamentals Top ↑

TopicWhat you will learn
Structure of a C programHeaders, main(), statements, comments and return value
Constants and variablesStoring values and using const
Local, global and static variablesScope and lifetime
Data typeschar, integer types, floating types and format specifiers
OperatorsArithmetic, relational, logical, assignment and increment operators
printf()Formatted output
scanf()Formatted keyboard input
CommentsSingle-line and block comments
FunctionsCreating and calling user-defined functions
if...elseConditional execution
switchChoosing among several cases
for loopCount-controlled repetition
while loopCondition-controlled repetition
do...while loopRun the loop body before testing the condition
getchar() / putchar()Character input and output

Simple Input and Output Example Top ↑

#include <stdio.h>

int main(void) {
    int age;

    printf("Enter your age: ");
    scanf("%d", &age);
    printf("Age: %d\n", age);

    return 0;
}

The ampersand in &age passes the address where scanf() should store the integer.

C Tutorials





plus2net.com






✖
We use cookies to improve your browsing experience. . Learn more
HTML MySQL PHP JavaScript ASP Photoshop Articles Contact us
© 2000-2026 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer