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;
}

Types of C Variables

C Programming Tutorial

An entity that may vary during program execution is called a variable. Variable names are names given to locations in memory. These locations can contain integer, real or character constants. In any language, the types of variables that it can support depend on the types of constants that it can handle. This is because a particular type … Read more

MySQL Error: 1064 SQLSTATE: 42000

MySQL Cluster

Error: 1064 SQLSTATE: 42000 (ER_PARSE_ERROR) Message: %s near ‘%s’ at line %d Error #1064 means that MySQL can’t understand your command. To fix it: Read the error message. It tells you exactly where in your command MySQL got confused. Check the manual. By comparing against what MySQL expected at that point, the problem is often … Read more

JavaScript – While Loops

java script

While writing a program, you may encounter a situation where you need to perform an action over and over again. In such situations, you would need to write loop statements to reduce the number of lines. JavaScript supports all the necessary loops to ease down the pressure of programming. The while Loop The most basic … Read more

The C Character Set : Constants, Variables and Keywords

C Programming Tutorial

A character denotes any alphabet, digit or special symbol used to represent information. Here is the list of valid character set (Alphabets, Numbers and Symbols) allowed in C. The alphabets, numbers and special symbols when properly combined form constants, variables and keywords. Let us see what are ‘constants’ and ‘variables’ in C. Constant and Variable … Read more

JavaScript Operator

javascript

Let us take a simple expression 4 + 5 is equal to 9. Here 4 and 5 are calledoperands and ‘+’ is called the operator. JavaScript supports the following types of operators. Arithmetic Operators Comparision Operators Logical (or Relational) Operators Assignment Operators Conditional (or ternary) Operators Lets have a look on all operators one by … Read more