What is C?
C is a general-purpose programming language created by Dennis Ritchie at the Bell Laboratories in 1972.
It is a very popular language, despite being old. The main reason for its popularity is because it is a fundamental language in the field of computer science.
C is strongly associated with UNIX, as it was developed to write the UNIX operating system.
Why Learn C?
- It is one of the most popular programming languages in the world
- If you know C, you will have no problem learning other popular programming languages such as Java, Python, C++, C#, etc, as the syntax is similar
- C is very fast, compared to other programming languages, like Java and Python
- C is very versatile; it can be used in both applications and technologies
Difference between C and C++
- C++ was developed as an extension of C, and both languages have almost the same syntax
- The main difference between C and C++ is that C++ support classes and objects, while C does not
Make a Snake Game With C
Here is a sample code, of snake game with c.
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
int width = 20, height = 20, gameOver;
int x, y, fruitX, fruitY, score;
void setup()
{
gameOver = 0;
x = width / 2;
y = width / 2;
label1:
fruitX = rand() % 20;
if (fruitX == 0)
{
goto label1;
}
label2:
fruitY = rand() % 20;
if (fruitY == 0)
{
goto label2;
}
return;
}
void draw()
{
int i, j;
for (i = 0; i < width; i++)
{
for (j = 0; j < height; j++)
{
if (i == 0 || i == height - 1 || j == 0 || j == width - 1)
{
printf("*");
}
else
{
if (i == x && j == y)
{
printf("O");
}
else if (i == fruitX && j == fruitY)
{
printf("F");
}
else
{
printf(" ");
}
}
}
}
return;
}
int main()
{
setup();
draw();
return 0;
}
Thanks…


.jpeg)
