Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
17 views

C Programming Basics

The document provides an overview of basic C programming syntax, including the use of printf() for output, loops (for and while), and if-else statements. It includes simple program examples such as printing 'Hello, World!' and performing basic arithmetic operations. These examples illustrate fundamental concepts for beginners in C programming.

Uploaded by

jaycepaul395
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views

C Programming Basics

The document provides an overview of basic C programming syntax, including the use of printf() for output, loops (for and while), and if-else statements. It includes simple program examples such as printing 'Hello, World!' and performing basic arithmetic operations. These examples illustrate fundamental concepts for beginners in C programming.

Uploaded by

jaycepaul395
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

C Programming Basics

Key Syntax in C:

1. printf(): Used to print output.

Example: printf("Hello, World!\n");

2. Loops:

- for loop: Repeats a block of code a specific number of times.

Example: for(int i = 0; i < 5; i++) { printf("%d\n", i); }

- while loop: Repeats a block of code while a condition is true.

Example: while(x > 0) { printf("%d\n", x--); }

3. if-else Statements:

Example:

if (x > 0) {

printf("Positive\n");

} else {

printf("Non-positive\n");

Simple Programs:

1. "Hello, World!"

#include <stdio.h>

int main() {
printf("Hello, World!\n");

return 0;

2. Basic Arithmetic Operations:

#include <stdio.h>

int main() {

int a = 5, b = 3;

printf("Sum: %d\n", a + b);

printf("Difference: %d\n", a - b);

return 0;

You might also like