# C Programming Code Examples

## Learn C Language

### line() Function in C Programming Language

**line() Function in C**

**Syntax for line() Function in C**

#include <graphics.h>
void line(int x1, int y1, int x2, int y2);

x1

X coordinate of first point
y1

Y coordinate of first point.
x2

X coordinate of second point.
y2

Y coordinate of second point.
This is a predefined function named line which is used to draw a line on the output screen. It takes 4 arguments, first two parameters represent an initial point and the last two arguments are for the final points of the line.
/* draw a line from a point(x1,y1) to point(x2,y2) by line() function example */
/*C graphics program to draw a line.*/
#include <graphics.h>
#include <conio.h>
main()
{
int gd = DETECT, gm;
//init graphics
initgraph(&gd, &gm, "C:/TURBOC3/BGI");
/*
if you are using turboc2 use below line to init graphics:
initgraph(&gd, &gm, "C:/TC/BGI");
*/
//draw a line
/*
line() function description
parameter left to right
x1: 100
y1: 100
x2: 200
y2: 100
*/
line(100,100,200,100); //will draw a horizontal line
line(10,10,200,10); //will draw another horizonatl line
getch();
closegraph();
return 0;
}

C program just print array in reversed order. It does not reverses the array. Here I am writing the first basic logic to reverse an array. It uses above approach to access array element in...

C Program checks whether the Singly Linked list is a palindrome. A Palindrome is a Pattern in List in which the contents when read from front is the same as when read from last. So

C Programming language code for circular queue implementation through Array. Add element to Circular Queue. Delete element from the Circular Queue. Do you want to do

Program calculates the simple interest given the principal amount, rate of interest & time. The Formula to calculate the Simple interest is: simple_interest = (p * t * r) / 100 where p...

C program Read two strings and Concatenate them, without using library functions. Display the 'Concatenated String'. Take two strings as input and store them in the arrays string1 and