Supercharge your development with unmatched features:
Access a full terminal environment, run Linux commands, and manage your project’s dependencies directly within the IDE.
Browse and interact with websites directly within the IDE. Supports real-time interaction with web content without leaving the workspace.
Manage your project files and directories effortlessly within the IDE. Create, edit, rename, move, and delete files—all in one place.
Experience seamless code editing with real-time syntax highlighting, tab support, and intelligent code suggestions for a smoother development workflow.
C is a general-purpose, procedural programming language. It is known for its efficiency and is widely used for system programming, developing operating systems, embedded systems, and applications.
gcc --version
in the terminal (if using GCC).Let’s write our first C program:
#include <stdio.h>
int main() {
printf("Hello, World!
");
return 0;
}
Save this code in a file named hello.c
, then compile and run it:
gcc hello.c -o hello
./hello
In C, variables are declared with specific data types. Here are some common data types:
#include <stdio.h>
int main() {
int x = 10; // Integer
float y = 3.14; // Float
char name = 'A'; // Character
printf("x = %d, y = %.2f, name = %c
", x, y, name);
return 0;
}
Conditional statements in C include if
, else if
, and else
.
#include <stdio.h>
int main() {
int num = 10;
if (num > 0) {
printf("Positive number
");
} else if (num == 0) {
printf("Zero
");
} else {
printf("Negative number
");
}
return 0;
}
C supports for
, while
, and do-while
loops.
#include <stdio.h>
int main() {
for (int i = 0; i < 5; i++) {
printf("%d
", i);
}
return 0;
}
#include <stdio.h>
int main() {
int count = 0;
while (count < 5) {
printf("%d
", count);
count++;
}
return 0;
}
Functions in C help to modularize code.
#include <stdio.h>
void greet(char name[]) {
printf("Hello, %s!
", name);
}
int main() {
greet("Alice");
return 0;
}
Arrays in C are used to store multiple values of the same data type.
#include <stdio.h>
int main() {
int numbers[] = {1, 2, 3, 4, 5};
for (int i = 0; i < 5; i++) {
printf("%d
", numbers[i]);
}
return 0;
}
Structures in C allow grouping of variables of different data types.
#include <stdio.h>
struct Student {
char name[50];
int age;
float marks;
};
int main() {
struct Student s1 = {"John", 21, 85.5};
printf("Name: %s, Age: %d, Marks: %.2f
", s1.name, s1.age, s1.marks);
return 0;
}
File handling in C is done using FILE
pointers.
#include <stdio.h>
int main() {
FILE *file = fopen("example.txt", "w");
fprintf(file, "Hello, C Language!
");
fclose(file);
file = fopen("example.txt", "r");
char buffer[100];
fgets(buffer, 100, file);
printf("%s", buffer);
fclose(file);
return 0;
}
Pointers in C store the memory address of a variable.
#include <stdio.h>
int main() {
int num = 10;
int *ptr = #
printf("Value: %d, Address: %p
", *ptr, ptr);
return 0;
}
C has a variety of libraries to simplify development. Some commonly used libraries are: