C program to print map of India [ C Tutorials ]

The string is a run-length encoding of the map of India. Alternating characters in the string stores how many times to draw a space, and how many times to draw an exclamation mark consecutively.

// C program to print map of India
#include <stdio.h>

int main()
{
int a = 10, b = 0, c = 10;

// The encoded string after removing first 31 characters
// Its individual characters determine how many spaces
// or exclamation marks to draw consecutively.
char* str = “TFy!QJu ROo TNn(ROo)SLq SLq ULo+UHs UJq ”
“TNn*RPn/QPbEWS_JSWQAIJO^NBELPeHBFHT}TnALVlBL”
“OFAkHFOuFETpHCStHAUFAgcEAelclcn^r^r\\tZvYxXyT|S~Pn SPm ”
“SOn TNn ULo0ULo#ULo-WHq!WFs XDt!”;

while (a != 0)
{
// read each character of encoded string
a = str[b++];
while (a– > 64)
{
if (++c == 90) // ‘Z’ is 90 in ascii
{
// reset c to 10 when the end of line is reached
c = 10;     // ‘\n’ is 10 in ascii

// print newline
putchar(‘\n’); // or putchar(c);
}
else
{
// draw the appropriate character
// depending on whether b is even or odd
if (b % 2 == 0)
putchar(‘!’);
else
putchar(‘ ‘);
}
}
}

return 0;
}

C program to print happy holi

c program to sort array

C program to print happy holi Here is the simple program written in c to Print Happy Holi.   #include<stdio.h> #include<conio.h> void main() { printf(“HAPPY HOLI “); getch(); }    

Pascal trangle program in c

Pascal trangle program in c Pascal Triangle is a Triangle form which, each number is the sum of immediate top row near by numbers. The Value of edge is always 1. 1 1 1 1 2 1 1 3 3 1 1 4 6 4 1 Let’s Start C program:   #include <stdio.h> int main() … Read more

Linear search program in c

c program to sort array

Linear search program in c   #include <stdio.h> int main() { int array[100], search, c, n; printf(“Enter number of elements in array\n”); scanf(“%d”, &n); printf(“Enter %d integer(s)\n”, n); for (c = 0; c < n; c++) scanf(“%d”, &array[c]); printf(“Enter a number to search\n”); scanf(“%d”, &search); for (c = 0; c < n; c++) { if … Read more

Sorting program in c

c program to sort array

Sorting program in c /* * C program to accept N numbers and arrange them in an ascending order */ #include <stdio.h> void main() { int i, j, a, n, number[30]; printf(“Enter the value of N \n”); scanf(“%d”, &n); printf(“Enter the numbers \n”); for (i = 0; i < n; ++i) scanf(“%d”, &number[i]); for (i … Read more

Write a program to convert temperature Fahrenheit to Centigrade

temperature Fahrenheit to Centigrade degrees c program

Write a program to convert temperature Fahrenheit to Centigrade Input temperature in fahrenheit from user. Store it in some variable say fahrenheit. Apply the temperature conversion formula celsius = (fahrenheit – 32) * 5 / 9. Print the value of celsius. Example Input Temperature in fahrenheit = 205 Output Temperature in celsius = 96.11 C Temperature conversion formula … Read more

C program to reverse words in a string

c program reverse-words-in-string

C program to reverse words in a string This profram will invert each word occurring in the input string. Algorithm is very simple just scan the string and keep on storing characters until a space comes. If a space is found then we have found one word so we append null terminator and then reverse the … Read more

C program to draw circles in circles

C program to draw circles in circles

C program to draw circles in circles #include<graphics.h> #include<conio.h> #include<dos.h> main() { int gd = DETECT, gm, x, y, color, angle = 0; struct arccoordstype a, b; initgraph(&gd, &gm, “C:\\TC\\BGI”); delay(2000); while(angle<=360) { setcolor(BLACK); arc(getmaxx()/2,getmaxy()/2,angle,angle+2,100); setcolor(RED); getarccoords(&a); circle(a.xstart,a.ystart,25); setcolor(BLACK); arc(getmaxx()/2,getmaxy()/2,angle,angle+2,150); getarccoords(&a); setcolor(GREEN); circle(a.xstart,a.ystart,25); angle = angle+5; delay(50); } getch(); closegraph(); return 0; }  

traffic light program in c

traffic program in c

Traffic light program in c #include<graphics.h> #include<conio.h> #include<dos.h> #include<stdlib.h> main() { int gd = DETECT, gm, midx, midy; initgraph(&gd, &gm, “C:\\TC\\BGI”); midx = getmaxx()/2; midy = getmaxy()/2; setcolor(RED); settextstyle(SCRIPT_FONT, HORIZ_DIR, 3); settextjustify(CENTER_TEXT, CENTER_TEXT); outtextxy(midx, midy-10, “Traffic Light Simulation”); outtextxy(midx, midy+10, “Press any key to start”); getch(); cleardevice(); setcolor(WHITE); settextstyle(DEFAULT_FONT, HORIZ_DIR, 1); rectangle(midx-30,midy-80,midx+30,midy+80); circle(midx, midy-50, 22); … Read more