abbreviation


ஏ.அய் – AI – Amnesty International

ஏ.பி.சி – ABC – American Broatcasting Company

பிB.எம்.டப்ளிவ் – BMW – Bavarian Motor Works

மேலுள்ள உதாரணங்களைப் போன்றே கீழுள்ளவற்றையும் உச்சரிக்க வேண்டும்

DND – Do Not Disturb

FYI – For your Information

FBI – Federal Bureau of Investigation

GB – Great Britain

IOU – I Owe You

LOL – Laugh Out Loud

ISI – Inter-Services Intelligence

MP – Member of Parliament

UNM – Under New Management

VIP – Very Important Person

CB – Criminal Bureau

CID – Criminal Investigation Department

CAT – Committee against Torture

CAT – Convention against Torture and Other Cruel, Inhuman or Degrading Treatment or Punishment.

CEDAW – Committee on the Elimination of Discrimination against Women. (Convention on the Elimination of all Forms of Discrimination against Women.)

CERD – Committee on the Elimination of Racial Discrimination (Convention on the Elimination of Racial Discrimination.)

CESCR – Committee on Economic, Social and Cultural Rights.

CHR – Commission on Human Rights

CMW – Committee on the Protection of the Rights of All Migrant Workers and Members of Their Families

CRC – Committee on the Rights of the Child (Convention of the Rights of the Child)

CSW – Commission on the Status of Women

CBI – Central Bureau of Investigation or Intelligence

CDC – Commonwealth Development Corporation

CE – Civil Engineer

CIA – Criminal Investigation Agency

CIA – Central Interlligence Agency

CID – Criminal Investigation Department

DPI – Department of Public Information

ECOSOC – United Nations Economic and Social Council

FAQ – frequently asked questions

GAOR – General Assembly Official Records

HRC – Human Rights Committee

ICC – International Criminal Court

ICCPR – International Covenant on Civil and Political Rights

ICERD – International Convention on the Elimination of All Forms of Racial Discrimination

ICESCR – International Covenant on Economic, Social and Cultural Rights

ICRC – International Committee of the Red Cross

ILO – International Labour Organization

IPKF – Indian Peace Keeping Forces

LTTE – Liberation Tigers of Tamil Eelam

NGO – Non-governmental organization

OHCHR – Office of the High Commissioner for Human Rights

RAW – Research and Analysis Wing

UDHR – Universal Declaration of Human Rights

UN – United Nations

UNAMIR – United Nations Assistance Mission for Rwanda

UNAMSIL – United Nations Mission in Sierra Leone

UNAVEM III – United Nations Angola Verification Mission III

UNCLOS – United Nations Convention on the Law of the Sea, also known as LOS

UNCRO – United Nations Confidence Restoration Operation in Croatia

UNCTAD – United Nations Conference on Trade and Development

UNDCP – United Nations Drug Control Programme

UNDOF United Nations Disengagement Observer Force

UNDP – United Nations Development Programme

UNEP – United Nations Environment Programme

UNESCO United Nations Educational, Scientific, and Cultural Organization

UNFICYP – United Nations Peacekeeping Force in Cyprus

UNFPA – United Nations Population Fund

UNHCR – United Nations High Commissioner for Refugees

UNHCRHR – United Nations High Commissioner for Human Rights

UNICEF – United Nations Children’s Fund

UNICEP – United Nations International Comparison Programme

UNICRI – United Nations Interregional Crime and Justice Research Institute

UNIDIR – United Nations Institute for Disarmament Research

UNIDO – United Nations Industrial Development Organization

UNIFIL – United Nations Interim Force in Lebanon

UNIKOM – United Nations Iraq-Kuwait Observation Mission

UNITAR – United Nations Institute for Training and Research

UNMEE – United Nations Mission in Ethiopia and Eritrea

UNMIBH – United Nations Mission in Bosnia and Herzegovina

UNMIK – United Nations Interim Administration Mission in Kosovo

UNMIL – United Nations Mission in Liberia

UNMIS – United Nations Mission in the Sudan

UNMISET – United Nations Mission of Support in East Timor

UNMOGIP – United Nations Military Observer Group in India and Pakistan

UNMOP – United Nations Mission of Observers in Prevlaka

UNMOT – United Nations Mission of Observers in Tajikistan

UNMOVIC United Nations Monitoring and Verification Commission

UNOMIG – United Nations Observer Mission in Georgia

UNOCI – United Nations Operation in Côte d’Ivoire

UNOMSIL – United Nations Mission of Observers in Sierra Leone

UNOPS – United Nations Office of Project Services

UNRISD – United Nations Research Institute for Social Development

UNRWA – United Nations Relief and Works Agency for Palestine Refugees in the Near East

UNSC – United Nations Security Council

UNSMIH – United Nations Support Mission in Haiti

UNSSC – United Nations System Staff College

UNTAET – United Nations Transitional Administration in East Timor

UNTSO – United Nations Truce Supervision Organization

UNU – United Nations University

USA – United States of America

USSR – Union of Soviet Socialist Republics (தற்போது உடைந்துவிட்டது)

UAE – United Arab Emirates

UK – United Kingdom (நான்கு நாடுகளின்-ஐக்கிய இராச்சியம் England, Northern Ireland, Scotland, Wales.)

NAACP – National Association for the Advancement of Colored People

கல்விக்கான தகமைகளின் சிலச் சுருக்கங்கள்

BA – Bachelor of Arts

BCL – Bachelor of Civil Law

BGL – Bachelor of General Law

B.Com., – Bachelor of Commerce

BD – Bachelor of Divinity

BDS – Bachelor of Dental Surgery

BL – Bachelor of Law

B.Lit., – Bachelor of Literature

BM – Bachelor of Medicine

B.Mus., – Bachelor of Music

B.Sc., – Bachelor of Science

BVSc., – Bachelor of Veterinary Science

DM – Doctor of Medicine

DSE – Director of School Education

DPH – Director of Public Instruction

DPH – Diploma in Public Health

D.Sc., – Doctor of Science

MA – Master of Arts

கணனித் துறைசார் சிலச் சுருக்கங்கள்

AMD – Advanced Micro Devices

API – Application Programming Interface

CD – Compact Disc

CD-R – CD-Recordable

CD-ROM – CD Read-Only Memory

CD-RW – CD Re-Writable

CPU – Central Processing Unit

DRAM – Dynamic Random Access Memory

DVD – Digital Video Disc

WWW – World Wide Web

சொற்களின் சுருக்கங்கள்

அநேகமாக இவற்றில் முதல் எழுத்து ”கெப்பிட்டல்” எழுத்தாகவும் அதன் பின் வருபவை “சிம்பல்” எழுத்தாகவும் வரும். சிம்பல் எழுத்துக்களில் மட்டுமே எழுதப்படுபவைகளும் உள்ளன.

Mr. – Mister (always abbreviated)

Mrs. – Mistress (always abbreviated)

இச்சுருக்கங்கள் இரண்டும் பேசும் பொழுது முழுச்சொற்களாக பேசப்பட்டாலும், எழுதும் பொழுது எப்பொழுதும் சுருக்கமாகவே எழுதப்படுகின்றன.

kg – kilogram(s)
km – kilometer(s)

B.C. – Before Christ
A.D. – Anno Domini (in the year of the Lord) (லத்தீன் சொற்கள்)

a.m. – Ante Meridiem – முற்பகல் (before midday) (லத்தீன் சொற்கள்)
p.m. – Post Meridiem – பிற்பகல் (after midday) (லத்தீன் சொற்கள்)

etc. – et cetera (“and the others”, “and other things”, “and the rest”) (லத்தீன் சொற்கள்)

e.g. – exempli gratia (means “for example) (லத்தீன் சொற்கள்)

AC – Alternating Current
DC – Direct Current

Ltd – Limited

Acronyms

இவற்றை நாம் மேலே கற்றதைப் போல் சொற்களின் முதல் எழுத்துக்களை உச்சரித்ததுப் பேசப்படுவதில்லை. சொற்களின் முதல் எழுத்துக்களை கூட்டுச்சேர்த்து ஒரு புதியச் சொல் போலவே பேசப்படுகின்றது. (In this case the first letters from each word actually form another word)

அநேகமாக சொற்கள் என்றே நினைத்து பேசும் பலருக்கு, இவை பலக் கூட்டுச்சொற்களின் “சுருக்கம்” என்பது தெரியாமலும் இருக்கலாம்.

உதாரணம்:

LASER – Light Amplification by Stimulated Emission of Radiation

இதனை “எல்-ஏ-எஸ்-ஈ-ஆர்” என உச்சரிப்பதில்லை. “லேஸzர்” என்றே உச்சரிக்க வேண்டும். இதுப்போன்ற சுருக்கங்களையே ஆங்கிலத்தில் “Acronym” என்றழைக்கின்றனர். மேலும் சில “Acronyms”.

SARS – Severe Acute Respiratory Syndrome.

AIDS – Acquired Immune Deficiency Syndrome.

BAFTA – British Academy of Film and Television Arts.

DEFRA – Department for Environment Foods and Rural Affairs.

JPEG – Joint Photographic Experts Group.

SALT – Strategic Arms Limitation Treaty.

NATO – North Atlantic Treaty Organization.

NASA – National Aeronautical and Space Administration.

OPEC – Organization of Petroleum Exporting Countries.

WHO – World Health Organization.

RADAR – Radio Detection And Ranging.

RAM – Random Access Memory.

introduces its first computer


Below is a listing of some of the major computers companies first computers.

Compaq – In March 1983, Compaq released its first computer and the first 100% IBM compatible computer the “Compaq Portable.”
Dell – In 1985, Dell introduced its first computer, the “Turbo PC.”
Hewlett Packard – In 1966, Hewlett Packard released its first general computer, the “HP-2115.”
NEC – In 1958, NEC builds its first computer the “NEAC 1101.”
Toshiba – In 1954, Toshiba introduces its first computer, the “TAC” digital computer.

The History of Computers


Computer History
1936
Konrad Zuse – Z1 ComputerFirst freely programmable computer.
1942
John Atanasoff & Clifford Berry
ABC ComputerWho was first in the computing biz is not always as easy as ABC.
1944
Howard Aiken & Grace Hopper
Harvard Mark I ComputerThe Harvard Mark 1 computer.
1946
John Presper Eckert & John W. Mauchly
ENIAC 1 Computer20,000 vacuum tubes later…
1948
Frederic Williams & Tom Kilburn
Manchester Baby Computer & The Williams TubeBaby and the Williams Tube turn on the memories.
1947/48
John Bardeen, Walter Brattain & Wiliam Shockley
The TransistorNo, a transistor is not a computer, but this invention greatly affected the history of computers.
1951
John Presper Eckert & John W. Mauchly
UNIVAC ComputerFirst commercial computer & able to pick presidential winners.
1953
International Business Machines
IBM 701 EDPM ComputerIBM enters into ‘The History of Computers’.
1954
John Backus & IBM
FORTRAN Computer Programming LanguageThe first successful high level programming language.
1955
(In Use 1959)
Stanford Research Institute, Bank of America, and General Electric
ERMA and MICRThe first bank industry computer – also MICR (magnetic ink character recognition) for reading checks.
1958
Jack Kilby & Robert Noyce
The Integrated CircuitOtherwise known as ‘The Chip’
1962
Steve Russell & MIT
Spacewar Computer GameThe first computer game invented.
1964
Douglas Engelbart
Computer Mouse & WindowsNicknamed the mouse because the tail came out the end.
1969
ARPAnetThe original Internet.
1970
Intel 1103 Computer MemoryThe world’s first available dynamic RAM chip.
1971
Faggin, Hoff & Mazor
Intel 4004 Computer MicroprocessorThe first microprocessor.
1971
Alan Shugart &IBM
The “Floppy” DiskNicknamed the “Floppy” for its flexibility.
1973
Robert Metcalfe & Xerox
The Ethernet Computer NetworkingNetworking.
1974/75
Scelbi & Mark-8 Altair & IBM 5100 ComputersThe first consumer computers.
1976/77
Apple I, II & TRS-80 & Commodore Pet ComputersMore first consumer computers.
1978
Dan Bricklin & Bob Frankston
VisiCalc Spreadsheet SoftwareAny product that pays for itself in two weeks is a surefire winner.
1979
Seymour Rubenstein & Rob Barnaby
WordStar SoftwareWord Processors.
1981
IBM
The IBM PC – Home ComputerFrom an “Acorn” grows a personal computer revolution
1981
Microsoft
MS-DOS Computer Operating SystemFrom “Quick And Dirty” comes the operating system of the century.
1983
Apple Lisa ComputerThe first home computer with a GUI, graphical user interface.
1984
Apple Macintosh ComputerThe more affordable home computer with a GUI.
1985
Microsoft WindowsMicrosoft begins the friendly war with Apple.
SERIES TO BE CONTINUED………

SSLC Topper 2012


First Rank: 497 – Srinath – P.R public Hr Sec School, Tanjavur

Second Rank : 496 – (6 Students)

Maha Lakshmi (SJS Matric. School, Nellai)
Kavain ( Cheran. Matric. School, Karoor)
Akila ( Vysa vidyalaya, Chengelpet)
Jenkin (nagerkoil)
Nadini
Swathi( Erodu)

Third Rank : 495 (11 Students)

Surya ( Sivakasi – Lions school)
Sharmila ( Erode)
Amirtha( Thirupathur)
Pooja Shree ( SRV School, Namakal )
Justin Savior ( kalaimagal Hr Sec School, Ponari )
Dharani ( Vivek Vidhyalaya)
Rajeshwari
Shree Thara
Vinmeetha
Abishek

Toppers In Tamil :

Sibi Chakravarthi ( Erode)
Nivetha (Chennai)
Bhuvaneswari (Thiruthani)

District Wise SSLC Samacheer Kalvi Toppers:

1) Chennai
2) Madurai
3) Coimbatore (Kovai)
4) Tiruchi (Trichy)

Angloindian Topper 2012 :
First Rank:

Second Rank :

Third Rank :

No. Of Students scored Centum in Maths = 1141 ( Last Year = 12566)
No. Of Students scored Centum in Science = 9237
No. Of Students scored Centum in Social Science = 5305 ( Last Year = 756)
No. Of Students scored Centum in English =
No. Of Students scored Centum in Tamil = 3 ( Last Year = 1)
No. Of Students scored Centum in Hindi/ French e.t.c =

online c program test

10 programming languages stand out for their job


Among thousands, 10 programming languages stand out for their job marketability and wide use. If you’re looking to boost your career or learn something new, start here.

Knowing a handful of programming languages is seen by many as a harbor in a job market storm, solid skills that will be marketable as long as the languages are.

Yet, there is beauty in numbers. While there may be developers who have had riches heaped on them by knowing the right programming language at the right time in the right place, most longtime coders will tell you that periodically learning a new language is an essential part of being a good and successful Web developer.

“One of my mentors once told me that a programming language is just a programming language. It doesnt matter if youre a good programmer, its the syntax that matters,” Tim Huckaby, CEO of San Diego-based software engineering company CEO Interknowlogy.com, told eWEEK.

However, Huckaby said that while his company is “swimming” in work, hes having a nearly impossible time finding recruits, even on the entry level, that know specific programming languages.

“Were hiring like crazy, but were not having an easy time. Were just looking for attitude and aptitude, kids right out of school that know .Net, or even Java, because with that we can train them on .Net,” said Huckaby.

“Dont get fixated on one or two languages. When I started in 1969, FORTRAN, COBOL and S/360 Assembler were the big tickets. Today, Java, C and Visual Basic are. In 10 years time, some new set of languages will be the in thing. …At last count, I knew/have learned over 24 different languages in over 30 years,” Wayne Duqaine, director of Software Development at Grandview Systems, of Sebastopol, Calif., told eWEEK.

By picking the brains of Web developers and IT recruiters, eWEEK selected 10 programming languages that are a bonus for developers to add to their resumes. Even better, theyre great jumping-off points, with loads of job opportunities for younger recruits.

1. PHP
What it is: An open-source, interpretive, server-side, cross-platform, HTML scripting language, especially well-suited for Web development as it can be embedded into HTML pages.
Why you should learn it: Its particularly widely used. “High-speed scripting with caching, augmented with compiled code plug-ins (such as can be done with Perl and PHP) is where the future is. Building Web apps from scratch using C or COBOL is going the way of the dinosaur,” said Duquaine.
Job availabilities: 1,152*

2. C#
What it is: A general-purpose, compiled, object-oriented programming language developed by Microsoft as part of its .NET initiative, it evolved from C and C++
Why you should learn it: Its an essential part of the .Net framework. “Learning C#, which is just Java with a different name plate, is critical if you heavily use Microsoft,” said Duquaine.
Job availabilities: 5,111

3. AJAX (Asynchronous JavaScript and XML)
What it is: Though technically not a programming language, AJAX uses XHTML or HTML, JavaScript and XML to create interactive Web applications.
Why you should learn it: Ever since Google Maps put AJAX, well, on the map, the requests for AJAX-knowledgeable pros went through the roof. “The demand for AJAX knowledge is huge because its so damned hard to learn,” said Huckaby. Of note, Microsoft announced recently plans to release a tool named Atlas that will make AJAX easier to implement. “If Microsofts Atlas tool is successful, it would bring the extreme complexity and annoyance of AJAX to the average worker,” said Huckaby.
Job availabilities : 1,106

4. JavaScript
What it is: Not to be confused with Java, JavaScript is a an object-oriented, scripting programming language that runs in the Web browser on the client side. Its smaller than Java, with a simplified set of commands, easier to code and doesnt have to be compiled.
Why you should learn it: Embedded into HTML, its used in millions of Web pages to validate forms, create cookies, detect browsers and improve the design. With its simplicity to learn as well as wide use, its considered a great bang for your educational buck.
Job availabilities: 4,406

5. Perl
What it is: Perl is an open-source, cross-platform, server-side interpretive programming language used extensively to process text through CGI programs.
Why you should learn it: Perls power in processing of piles of text has made it very popular and widely used to write Web server programs for a range of tasks. “Learning some form of scripting language, such as Perl or PHP is critical if you are doing Web apps,” said Duquaine.
Job availabilities: 4,810

6. C
What it is: A standardized, general-purpose programming language, its one of the most pervasive languages and the basis for several others (such as C++).
Why you should learn it: “Learning C is crucial. Once you learn C, making the jump to Java or C# is fairly easy, because a lot of the syntax is common. Also, a lot of C syntax is used in scripting languages,” said Duquaine.
Job availabilities: 6,164, including all derivatives

7. Ruby and Ruby on Rails
What they are: Ruby is a dynamic, object-oriented, open-source programming language; Ruby on Rails is an open-source Web application framework written in Ruby that closely follows the MVC (Model-View-Controller) architecture.
Why you should learn it: With a focus on simplicity, productivity and letting the computers do the work, in a few years, its usage has spread quickly. As a bonus, many find it easy to learn.
Job availabilities : 210 and 54, respectively

8. Java
What it is: An object-oriented programming language developed by James Gosling and colleagues at Sun Microsystems in the early 1990s.
Why you should learn it: Hailed by many developers as a “beautiful” language, it is central to the non-.Net programming experience. “Learning Java is critical if you are non-Microsoft,” said Duquaine.
Job availabilities: 14,408

9. Python
What it is: An interpreted, dynamically object-oriented, open-source programming language that utilizes automatic memory management.
Why you should learn it: Designed to be a highly readable, minimalist language, many say it has a sense of humor (spam and eggs, rather than foo and bar), Python is used extensively by Google as well as in academia because of its syntactic simplicity.
Job availabilities: 811

10. VB.Net (Visual Basic .Net)
What it is: An object-oriented language implemented on Microsofts .Net framework.
Why you should learn it: Most argue that VB.Net is currently more popular than ever and one of the only “must-learns.” “It is currently dominating in adoption and that is where all the work is,” said Huckaby.
Job availabilities: 2,090

c programs


hello world example

#include

int main()
{
printf(“Hello world\n”);
return 0;
}

Hello world program in c

We may store “hello world” in a character array and then print it.

#include

int main()
{
char string[] = “Hello World”;

printf(“%s\n”, string);

return 0;
}

c program print integer

This c program first inputs an integer and then prints it. Input is done using scanf function and number is printed on screen

using printf.
C programming code

#include

main()
{
int a;

printf(“Enter an integer\n”);
scanf(“%d”, &a);

printf(“Integer that you have entered is %d\n”, a);

return 0;
}

Output:
input number

c program to add two numbers

C program to add two numbers: This c language program perform the basic arithmetic operation of addition on two numbers and

then prints the sum on the screen. For example if the user entered two numbers as 5, 6 then 11 ( 5 + 6 ) will be printed on

the screen.
C programming code

#include

main()
{
int a, b, c;

printf(“Enter two numbers to add\n”);
scanf(“%d%d”,&a,&b);

c = a + b;

printf(“Sum of entered numbers = %d\n”,c);

return 0;
}

program to check odd or even using modulus operator

#include

main()
{
int n;

printf(“Enter an integer\n”);
scanf(“%d”,&n);

if ( n%2 == 0 )
printf(“Even\n”);
else
printf(“Odd\n”);

return 0;
}

C program to check odd or even using bitwise operator

#include

main()
{
int n;

printf(“Enter an integer\n”);
scanf(“%d”,&n);

if ( n & 1 == 1 )
printf(“Odd\n”);
else
printf(“Even\n”);

return 0;
}

C program to check odd or even without using bitwise or modulus operator

#include

main()
{
int n;

printf(“Enter an integer\n”);
scanf(“%d”,&n);

if ( (n/2)*2 == n )
printf(“Even\n”);
else
printf(“Odd\n”);

return 0;
}

Find odd or even using conditional operator

#include

main()
{
int n;

printf(“Enter an integer\n”);
scanf(“%d”,&n);

n%2 == 0 ? printf(“Even number\n”) : printf(“Odd number\n”);

return 0;
}

Comments
1 comment posted
To check the given no. is even or odd without using % operator

#include

main()
{
char *a[]={“Odd”, “Even”};
int n;

printf(“Enter an integer\n”);
scanf(“%d”,&n);

printf(“%s\n”, a[(n/2)*2 == n]);

return 0;
}

C program to perform addition, subtraction, multiplication and division

C program to perform basic arithmetic operations i.e. addition , subtraction, multiplication and division of two numbers.

Numbers are assumed to be integers and will be entered by the user.
C programming code

#include

main()
{
int first, second, add, subtract, multiply;
float divide;

printf(“Enter two integers\n”);
scanf(“%d%d”, &first, &second);

add = first + second;
subtract = first – second;
multiply = first * second;
divide = first / (float)second; //typecasting

printf(“Sum = %d\n”,add);
printf(“Difference = %d\n”,subtract);
printf(“Multiplication = %d\n”,multiply);
printf(“Division = %.2f\n”,divide);

return 0;
}

In c language when we divide two integers we get integer result for example 5/2 evaluates to 2. As a general rule

integer/integer = integer and float/integer = float or integer/float = float. So we convert denominator to float in our

program, you may also write float in numerator. This explicit conversion is known as typecasting.

Arithmetic operations.

Output of program:

c program to check whether input alphabet is a vowel or not

This code checks whether an input alphabet is a vowel or not. Both lower-case and upper-case are checked.
C programming code

#include

main()
{
char ch;

printf(“Enter a character\n”);
scanf(“%c”, &ch);

if (ch == ‘a’ || ch == ‘A’ || ch == ‘e’ || ch == ‘E’ || ch == ‘i’ || ch == ‘I’ || ch ==’o’ || ch==’O’ || ch == ‘u’ || ch ==

‘U’)
printf(“%c is a vowel.\n”, ch);
else
printf(“%c is not a vowel.\n”, ch);

return 0;
}

Output:
check character case output
Check vowel using switch statement

#include

main()
{
char ch;

printf(“Enter a character\n”);
scanf(“%c”, &ch);

switch(ch)
{
case ‘a’:
case ‘A’:
case ‘e’:
case ‘E’:
case ‘i’:
case ‘I’:
case ‘o’:
case ‘O’:
case ‘u’:
case ‘U’:
printf(“%c is a vowel.\n”, ch);
break;
default:
printf(“%c is not a vowel.\n”, ch);
}

return 0;
}

Function to check vowel

int check_vowel(char a)
{
if (a >= ‘A’ && a <= 'Z')
a = a + 'a' – 'A'; /* Converting to lower case or use a = a + 32 */

if (a == 'a' || a == 'e' || a == 'i' || a == 'o' || a == 'u')
return 1;

return 0;
}

c program to check leap year

c program to check leap year: c code to check leap year, year will be entered by the user. Please read the leap year article

before reading the code, it will help you to understand the program.
C programming code

#include

int main()
{
int year;

printf(“Enter a year to check if it is a leap year\n”);
scanf(“%d”, &year);

if ( year%400 == 0)
printf(“%d is a leap year.\n”, year);
else if ( year%100 == 0)
printf(“%d is not a leap year.\n”, year);
else if ( year%4 == 0 )
printf(“%d is a leap year.\n”, year);
else
printf(“%d is not a leap year.\n”, year);

return 0;
}

add digits of number in c

C program to add digits of a number: Here we are using modulus operator(%) to extract individual digits of number and adding

them.
C programming code

#include

main()
{
int n, sum = 0, remainder;

printf(“Enter an integer\n”);
scanf(“%d”,&n);

while(n != 0)
{
remainder = n % 10;
sum = sum + remainder;
n = n / 10;
}

printf(“Sum of digits of entered number = %d\n”,sum);

return 0;
}

Factorial program in c

Factorial program in c: c code to find and print factorial of a number, three methods are given, first one uses a for loop,

second uses a function to find factorial and third using recursion. Factorial is represented using !, so five factorial will

be written as 5!, n factorial as n!. Also
n! = n*(n-1)*(n-2)*(n-3)…3.2.1 and zero factorial is defined as one i.e. 0!=1.
Factorial program in c using for loop

: Here we find factorial using for loop.

#include
#include

main()
{
int c, n, fact = 1;

printf(“Enter a number to calculate it’s factorial\n”);
scanf(“%d”,&n);

for( c = 1 ; c <= n ; c++ )
fact = fact*c;

printf("Factorial of %d = %d\n",n,fact);

getch();
return 0;
}

c program to find hcf and lcm

C program to find hcf and lcm: The code below finds highest common factor and least common multiple of two integers. HCF is

also known as greatest common divisor(GCD) or greatest common factor(gcf).
C programming code

#include

int main() {
int a, b, x, y, t, gcd, lcm;

printf(“Enter two integers\n”);
scanf(“%d%d”, &x, &y);

a = x;
b = y;

while (b != 0) {
t = b;
b = a % b;
a = t;
}

gcd = a;
lcm = (x*y)/gcd;

printf(“Greatest common divisor of %d and %d = %d\n”, x, y, gcd);
printf(“Least common multiple of %d and %d = %d\n”, x, y, lcm);

return 0;
}

C program to find hcf and lcm using recursion

#include

long gcd(long, long);

int main() {
long x, y, hcf, lcm;

printf(“Enter two integers\n”);
scanf(“%ld%ld”, &x, &y);

hcf = gcd(x, y);
lcm = (x*y)/hcf;

printf(“Greatest common divisor of %ld and %ld = %ld\n”, x, y, hcf);
printf(“Least common multiple of %ld and %ld = %ld\n”, x, y, lcm);

return 0;
}

long gcd(long a, long b) {
if (b == 0) {
return a;
}
else {
return gcd(b, a % b);
}
}

C program to find hcf and lcm using function

#include

long gcd(long, long);

int main() {
long x, y, hcf, lcm;

printf(“Enter two integers\n”);
scanf(“%ld%ld”, &x, &y);

hcf = gcd(x, y);
lcm = (x*y)/hcf;

printf(“Greatest common divisor of %ld and %ld = %ld\n”, x, y, hcf);
printf(“Least common multiple of %ld and %ld = %ld\n”, x, y, lcm);

return 0;
}

long gcd(long x, long y) {
if (x == 0) {
return y;
}

while (y != 0) {
if (x > y) {
x = x – y;
}
else {
y = y – x;
}
}

return x;
}

Decimal to binary conversion

C program to convert decimal to binary: c language code to convert an integer from decimal number system(base-10) to binary

number system(base-2). Size of integer is assumed to be 32 bits. We use bitwise operators to perform the desired task. We

right shift the original number by 31, 30, 29, …, 1, 0 bits using a loop and bitwise AND the number obtained with 1(one),

if the result is 1 then that bit is 1 otherwise it is 0(zero).
C programming code

#include

int main()
{
int n, c, k;

printf(“Enter an integer in decimal number system\n”);
scanf(“%d”, &n);

printf(“%d in binary number system is:\n”, n);

for (c = 31; c >= 0; c–)
{
k = n >> c;

if (k & 1)
printf(“1”);
else
printf(“0”);
}

printf(“\n”);

return 0;
}

Above code only prints binary of integer, but we may wish to perform operations on binary so in the code below we are storing

the binary in a string. We create a function which returns a pointer to string which is the binary of the number passed as

argument to the function.
C code to store decimal to binary conversion in a string

#include
#include

char *decimal_to_binary(int);

main()
{
int n, c, k;
char *pointer;

printf(“Enter an integer in decimal number system\n”);
scanf(“%d”,&n);

pointer = decimal_to_binary(n);
printf(“Binary string of %d is: %s\n”, n, t);

free(pointer);

return 0;
}

char *decimal_to_binary(int n)
{
int c, d, count;
char *pointer;

count = 0;
pointer = (char*)malloc(32+1);

if ( pointer == NULL )
exit(EXIT_FAILURE);

for ( c = 31 ; c >= 0 ; c– )
{
d = n >> c;

if ( d & 1 )
*(pointer+count) = 1 + ‘0’;
else
*(pointer+count) = 0 + ‘0’;

count++;
}
*(pointer+count) = ”;

return pointer1;
}

c program to find ncr and npr

c program to find nCr and nPr: This code calculate nCr which is n!/(r!*(n-r)!) and nPr = n!/(n-r)!
C program to find nCr using function

#include

long factorial(int);
long find_ncr(int, int);
long find_npr(int, int);

main()
{
int n, r;
long ncr, npr;

printf(“Enter the value of n and r\n”);
scanf(“%d%d”,&n,&r);

ncr = find_ncr(n, r);
npr = find_npr(n, r);

printf(“%dC%d = %ld\n”, n, r, ncr);
printf(“%dP%d = %ld\n”, n, r, npr);

return 0;
}

long find_ncr(int n, int r)
{
long result;

result = factorial(n)/(factorial(r)*factorial(n-r));

return result;
}

long find_npr(int n, int r)
{
long result;

result = factorial(n)/factorial(n-r);

return result;
}

long factorial(int n)
{
int c;
long result = 1;

for( c = 1 ; c <= n ; c++ )
result = result*c;

return ( result );
}

c program to add n numbers

This c program add n numbers which will be entered by the user. Firstly user will enter a number indicating how many numbers

user wishes to add and then user will enter n numbers. In the first c program to add numbers we are not using an array, and

using array in the second code.
C programming code

#include

int main()
{
int n, sum = 0, c, value;

printf(“Enter the number of integers you want to add\n”);
scanf(“%d”, &n);

printf(“Enter %d integers\n”,n);

for (c = 1; c <= n; c++)
{
scanf("%d",&value);
sum = sum + value;
}

printf("Sum of entered integers = %d\n",sum);

return 0;
}

C programming code using array

#include

int main()
{
int n, sum = 0, c, array[100];

scanf(“%d”, &n);

for (c = 0; c < n; c++)
{
scanf("%d", &array[c]);
sum = sum + array[c];
}

printf("Sum = %d\n",sum);

return 0;
}

c program to swap two numbers

C program to swap two numbers with and without using third variable, swapping in c using pointers, functions (Call by

reference) and using bitwise XOR operator, swapping means interchanging. For example if in your c program you have taken two

variable a and b where a = 4 and b = 5, then before swapping a = 4, b = 5 after swapping a = 5, b = 4
In our c program to swap numbers we will use a temp variable to swap two numbers. Swapping is used in sorting that is when we

wish to arrange numbers in a particular order either in ascending order or in descending order.
Swapping of two numbers in c

#include

int main()
{
int x, y, temp;

printf(“Enter the value of x and y\n”);
scanf(“%d%d”, &x, &y);

printf(“Before Swapping\nx = %d\ny = %d\n”,x,y);

temp = x;
x = y;
y = temp;

printf(“After Swapping\nx = %d\ny = %d\n”,x,y);

return 0;
}

Swapping of two numbers without third variable

You can also swap two numbers without using temp or temporary or third variable. In that case c program will be as shown :-

#include

int main()
{
int a, b;

printf(“Enter two integers to swap\n”);
scanf(“%d%d”, &a, &b);

a = a + b;
b = a – b;
a = a – b;

printf(“a = %d\nb = %d\n”,a,b);
return 0;
}

To understand above logic simply choose a as 7 and b as 9 and then do what is written in program. You can choose any other

combination of numbers as well. Sometimes it’s a good way to understand a program.
Swap two numbers using pointers

#include

int main()
{
int x, y, *a, *b, temp;

printf(“Enter the value of x and y\n”);
scanf(“%d%d”, &x, &y);

printf(“Before Swapping\nx = %d\ny = %d\n”, x, y);

a = &x;
b = &y;

temp = *b;
*b = *a;
*a = temp;

printf(“After Swapping\nx = %d\ny = %d\n”, x, y);

return 0;
}

Swapping numbers using call by reference

In this method we will make a function to swap numbers.

#include

void swap(int*, int*);

int main()
{
int x, y;

printf(“Enter the value of x and y\n”);
scanf(“%d%d”,&x,&y);

printf(“Before Swapping\nx = %d\ny = %d\n”, x, y);

swap(&x, &y);

printf(“After Swapping\nx = %d\ny = %d\n”, x, y);

return 0;
}

void swap(int *a, int *b)
{
int temp;

temp = *b;
*b = *a;
*a = temp;
}

C programming code to swap using bitwise XOR

#include

int main()
{
int x, y;

scanf(“%d%d”, &x, &y);

printf(“x = %d\ny = %d\n”, x, y);

x = x ^ y;
y = x ^ y;
x = x ^ y;

printf(“x = %d\ny = %d\n”, x, y);

return 0;
}

c program to reverse a number

C Program to reverse a number :- This program reverse the number entered by the user and then prints the reversed number on

the screen. For example if user enter 123 as input then 321 is printed as output. In our program we use modulus(%) operator

to obtain the digits of a number. To invert number look at it and write it from opposite direction or the output of code is a

number obtained by writing original number from right to left. To reverse large numbers use long data type or long long data

type if your compiler supports it, if you still have large numbers then use strings or other data structure.
C programming code

#include

main()
{
int n, reverse = 0;

printf(“Enter a number to reverse\n”);
scanf(“%d”,&n);

while (n != 0)
{
reverse = reverse * 10;
reverse = reverse + n%10;
n = n/10;
}

printf(“Reverse of entered number is = %d\n”, reverse);

return 0;
}

Palindrome Numbers

Palindrome number in c: A palindrome number is a number such that if we reverse it, it will not change. For example some

palindrome numbers examples are 121, 212, 12321, -454. To check whether a number is palindrome or not first we reverse it and

then compare the number obtained with the original, if both are same then number is palindrome otherwise not. C program for

palindrome number is given below.
Palindrome number algorithm

1. Get the number from user.
2. Reverse it.
3. Compare it with the number entered by the user.
4. If both are same then print palindrome number
5. Else print not a palindrome number.
Palindrome number program c

#include

main()
{
int n, reverse = 0, temp;

printf(“Enter a number to check if it is a palindrome or not\n”);
scanf(“%d”,&n);

temp = n;

while( temp != 0 )
{
reverse = reverse * 10;
reverse = reverse + temp%10;
temp = temp/10;
}

if ( n == reverse )
printf(“%d is a palindrome number.\n”, n);
else
printf(“%d is not a palindrome number.\n”, n);

return 0;
}

c program to print patterns of numbers and stars

These program prints various different patterns of numbers and stars. These codes illustrate how to create various patterns

using c programming. Most of these c programs involve usage of nested loops and space. A pattern of numbers, star or

characters is a way of arranging these in some logical manner or they may form a sequence. Some of these patterns are

triangles which have special importance in mathematics. Some patterns are symmetrical while other are not. Please see the

complete page and look at comments for many different patterns.

*
***
*****
*******
*********

We have shown five rows above, in the program you will be asked to enter the numbers of rows you want to print in the pyramid

of stars.
C programming code

#include

main()
{
int row, c, n, temp;

printf(“Enter the number of rows in pyramid of stars you wish to see “);
scanf(“%d”,&n);

temp = n;

for ( row = 1 ; row <= n ; row++ )
{
for ( c = 1 ; c < temp ; c++ )
printf(" ");

temp–;

for ( c = 1 ; c <= 2*row – 1 ; c++ )
printf("*");

printf("\n");
}

return 0;
}

Output:

stars pyramid

Consider the pattern
*
**
***
****
*****

to print above pattern see the code below:

#include

main()
{
int n, c, k;

printf(“Enter number of rows\n”);
scanf(“%d”,&n);

for ( c = 1 ; c <= n ; c++ )
{
for( k = 1 ; k <= c ; k++ )
printf("*");

printf("\n");
}

return 0;
}

For more patterns or shapes on numbers and characters see comments below and also see codes on following pages:
Floyd triangle
Pascal triangle
Comments
48 comments posted
i need a code for this pattern.

12345
1234
123
12
1

Posted by Guest on Fri, 26/08/2011 – 12:35
number pattern c code

#include

main()
{
int n, c, k, space;

scanf(“%d”, &n);

space = 0;

for ( k = n ; k >= 1 ; k– )
{
for ( c = 1 ; c <= space ; c++ )
printf(" ");

space++;

for ( c = 1 ; c <= k ; c++)
printf("%d", c);

printf("\n");
}

return 0;
}

Posted by adminPs on Fri, 26/08/2011 – 17:06
thanks for the patterns it

thanks for the patterns it really helped me a lot.
Posted by Guest on Tue, 23/08/2011 – 22:04
i need code of this pattern

A B C D E F G H
A B C D E F G
A B C D E F
A B C D E
A B C D
A B C
A B
A

Posted by Guest on Sat, 20/08/2011 – 18:07
c program for character pattern

#include

main()
{
char ch = ‘A’;
int n, c, k, space = 0;

scanf(“%d”, &n);

for ( k = n ; k >= 1 ; k– )
{
for ( c = 1 ; c <= space ; c++)
printf(" ");

space++;

for ( c = 1 ; c <= k ; c++ )
{
printf("%c ", ch);
ch++;
}

printf("\n");
ch = 'A';
}

return 0;
}

Posted by adminPs on Sat, 20/08/2011 – 21:29
c language

diamond pattern of stars
Posted by Guest on Sat, 20/08/2011 – 14:51
diamond pattern

Diamond pattern
Posted by adminPs on Fri, 26/08/2011 – 09:48
please help give me source code

1
01
010
1010
10101
Posted by Guest on Fri, 19/08/2011 – 17:38
c program to print pattern

#include

main()
{
int n, c, k, num = 1;

scanf(“%d”, &n);

for ( c = 1 ; c <= n ; c++ )
{
for ( k = 1 ; k <= c ; k++ )
{
printf("%d", num);

if ( num == 0 )
num = 1;
else
num = 0;
}
printf("\n");
}

return 0;
}

Posted by adminPs on Sat, 20/08/2011 – 08:43
can you write code for this

p
pr
pro
prog
progr
progra
program
Posted by Guest on Thu, 18/08/2011 – 21:20
pattern for string

Just input the string and press enter, corresponding pattern will be printed.

#include
#include

main()
{
char string[100];
int c, k, length;

printf(“Enter a string\n”);
gets(string);

length = strlen(string);

for ( c = 0 ; c < length ; c++ )
{
for( k = 0 ; k <= c ; k++ )
{
printf("%c", string[k]);
}
printf("\n");
}

return 0;
}

Posted by adminPs on Thu, 18/08/2011 – 21:59
c programming code

please get me the code of the c program to get the output as follows:

1
121
12321
1234321
123454321
Posted by Guest on Thu, 18/08/2011 – 20:40
c program to print number pattern

#include

main()
{
int n, c, k, x = 1;

scanf(“%d”, &n);

for ( c = 1 ; c <= n ; c++ )
{
for ( k = 1 ; k <= c ; k++ )
{
printf("%d", x);
x++;
}

x–;

for ( k = 1 ; k <= c – 1 ; k++ )
{
x–;
printf("%d", x);
}

printf("\n");
x = 1;
}

return 0;
}

Posted by adminPs on Thu, 18/08/2011 – 22:10
c++ code to print pattern

1 1
12 21
12321

Posted by Guest on Wed, 17/08/2011 – 19:15
c++ code to print pattern

#include

using namespace std;

main()
{
int n, k, c, space, x, num = 1;

cin >> n;

x = n;

for ( k = 1 ; k <= n ; k++ )
{
for ( c = 1 ; c <= k ; c++ )
{
cout << num;
num++;
}

num–;

for ( c = 1 ; c <= 2*x – 3 ; c++ )
cout << " ";

x–;

if ( k != n )
{
for ( c = 1 ; c <= k ; c++ )
{
cout << num;
num–;
}
}
else
{
num–;
for ( c = 1 ; c <= k – 1 ; c++ )
{
cout << num;
num–;
}
}

printf("\n");
num = 1;
}

return 0;
}

Posted by adminPs on Thu, 18/08/2011 – 17:14
may i get its source code

1
232
34543
4567654
567898765

Posted by Guest on Tue, 16/08/2011 – 21:34
c code for number pattern

#include

main()
{
int n, c, d, num = 1, space;

scanf(“%d”,&n);

space = n – 1;

for ( d = 1 ; d <= n ; d++ )
{
num = d;

for ( c = 1 ; c <= space ; c++ )
printf(" ");

space–;

for ( c = 1 ; c <= d ; c++ )
{
printf("%d", num);
num++;
}
num–;
num–;
for ( c = 1 ; c < d ; c++)
{
printf("%d", num);
num–;
}
printf("\n");

}

return 0;
}

Posted by adminPs on Thu, 18/08/2011 – 17:17
how to print this pattern

*******
***S***
**SSS**
*SSSSS*

where S represents Space

*******
*** ***
** **
* *

Posted by Guest on Sat, 13/08/2011 – 17:53
c code for star pattern

#include

main()
{
int n, c, k, space, r;

printf(“Enter number of rows\n”);
scanf(“%d”,&n);

space = 1;
r = n-1;

for( c = 1 ; c <= 2*n – 1 ; c++ )
printf("*");

printf("\n");

for ( k = 2 ; k <= n ; k++ )
{

for( c = 1 ; c <= r ; c++ )
printf("*");

for ( c = 1 ; c <= space ; c++ )
printf(" ");

space = 2*k-1;

for( c = 1 ; c <= r ; c++ )
printf("*");
r–;

printf("\n");
}

return 0;
}

Posted by adminPs on Sat, 13/08/2011 – 19:17
Doubt

In the program, instead of the statement space=2*k-1; , can we go for the statement, space+=2; ?
Posted by Guest on Mon, 22/08/2011 – 09:47
sure

You can use but don't forget to initialize variable space to one.
Posted by adminPs on Mon, 22/08/2011 – 13:01
code

guys i need the code for this

*
**
***
****
*****

Posted by Guest on Sat, 13/08/2011 – 17:15
star pattern source code

#include

main()
{
int n, c, k, space;

printf(“Enter number of rows\n”);
scanf(“%d”,&n);

space = n;

for ( k = 1 ; k <= n ; k++ )
{
for ( c = 1 ; c < space ; c++ )
printf(" ");

space–;

for( c = 1 ; c <= k ; c++ )
printf("*");

printf("\n");
}

return 0;
}

Posted by adminPs on Sat, 13/08/2011 – 17:29
i need a program to draw the below patern

1
22
333
4444
55555
Posted by Guest on Fri, 12/08/2011 – 18:48
number pattern source code

#include

main()
{
int n, c, k;

printf(“Enter number of rows\n”);
scanf(“%d”,&n);

for ( c = 1 ; c <= n ; c++ )
{
for( k = 1 ; k <= c ; k++ )
printf("%d", c);

printf("\n");
}

return 0;
}

Posted by adminPs on Fri, 12/08/2011 – 20:13
need help

i need program to print the following pattern ::

1
2 3
4 5 6
7 8 9 10
Posted by Guest on Thu, 11/08/2011 – 20:14
Floyd's triangle

This pattern is Floyd's triangle see Floyd's Triangle code.
Posted by adminPs on Fri, 12/08/2011 – 07:31
need a code in c to print below pattern

i want a code to print stars like below

*
**
***
****
***
**
*
Posted by Guest on Tue, 09/08/2011 – 21:46
stars pattern using c programming

#include

main()
{
int n, c, k;

printf(“Enter number of rows\n”);
scanf(“%d”,&n);

for ( c = 1 ; c <= n ; c++)
{
for ( k = 1 ; k = 0 ; c– )
{
for ( k = c ; k >= 0 ; k– )
printf(“*”);

printf(“\n”);
}

return 0;
}

Posted by adminPs on Tue, 09/08/2011 – 22:38
GET ME THE CODE OF A PROGRAM

GET ME THE CODE OF A PROGRAM TO GET OUTPUT AS FOLLOWS:

*
*A*
*A*A*
*A*A*A*

Posted by Guest on Tue, 09/08/2011 – 17:21
code to print pattern of stars and numbers

#include

main()
{
int n, c, k, space, count = 1;

printf(“Enter number of rows\n”);
scanf(“%d”,&n);

space = n;

for ( c = 1 ; c <= n ; c++)
{
for( k = 1 ; k < space ; k++)
printf(" ");

for ( k = 1 ; k 1 && count < c)
{
printf("A");
count++;
}
}

printf("\n");
space–;
count = 1;
}
return 0;
}

Posted by adminPs on Tue, 09/08/2011 – 21:46
codes for pyramid of stars.

i need this pattern
* * * * *
* * *
* *
*
Posted by Guest on Mon, 08/08/2011 – 13:18
code for pattern

#include

main()
{
int n, c, k, temp;

printf(“Enter number of rows\n”);
scanf(“%d”,&n);

temp = n;

for ( c = 1 ; c <= n ; c++ )
{
for( k = 1 ; k <= temp ; k++ )
printf("* ");

temp–;

printf("\n");
}

return 0;
}

Posted by adminPs on Mon, 08/08/2011 – 15:32
Please post the code for this

*
* *
* * *
* * * *

Please post the code to print the following shape as soon as possible.
Posted by Guest on Mon, 08/08/2011 – 13:01
code

#include

main()
{
int n, c, k;

printf(“Enter number of rows\n”);
scanf(“%d”,&n);

for ( c = 1 ; c <= n ; c++ )
{
for( k = 1 ; k <= c ; k++ )
printf("* ");

printf("\n");
}

return 0;
}

Posted by adminPs on Mon, 08/08/2011 – 15:29
please help

i need c program to print no in this format
1
1 2
1 2 3
1 2 3 4
Posted by Guest on Sat, 06/08/2011 – 13:59
source code

#include

main()
{
int number = 1, n, c, k;

printf(“Enter number of rows\n”);
scanf(“%d”,&n);

for ( c = 1 ; c <= n ; c++ )
{
for( k = 1 ; k <= c ; k++ )
{
printf("%d ", number);
number++;
}

number = 1;

printf("\n");
}

return 0;
}

Posted by adminPs on Sun, 07/08/2011 – 11:32
Thanks giving and suggestion

Thanks for the pyramid program!! Please help me in the same problem.
Can't we directly print k directly instead of number(in 2nd inner for loop)?

I have tried it but output gives garbage values!!why does this happen? Please help me!
Posted by Guest on Mon, 08/08/2011 – 22:02
number pattern code

You are right there is no need to use variable number you can use k directly as in code below:

#include

main()
{
int n, c, k;

printf(“Enter number of rows\n”);
scanf(“%d”,&n);

for ( c = 1 ; c <= n ; c++ )
{
for( k = 1 ; k <= c ; k++ )
printf("%d ", k);

printf("\n");
}

return 0;
}

Posted by adminPs on Tue, 09/08/2011 – 11:19
i need a code in C to print pyramid of stars

i need a code in C to print stars like this

*
* *
* * *
* * * *

please help?
Posted by Guest on Fri, 05/08/2011 – 11:53
c code to print pattern

#include

main()
{
int n, c, k = 2, j;

printf(“Enter number of rows\n”);
scanf(“%d”,&n);

for ( j = 1 ; j <= n ; j++ )
{
for ( c = 1 ; c <= 2*n-k ; c++)
printf(" ");

k = k + 2;

for ( c = 1 ; c <= j ; c++)
printf("* ");

printf("\n");
}

getch();
return 0;
}

c program to print diamond pattern

Diamond pattern in c: This code print diamond pattern of stars. Diamond shape is as follows:

*
***
*****
***
*

C programming code

#include

int main()
{
int n, c, k, space = 1;

printf(“Enter number of rows\n”);
scanf(“%d”, &n);

space = n – 1;

for (k = 1; k <= n; k++)
{
for (c = 1; c <= space; c++)
printf(" ");

space–;

for (c = 1; c <= 2*k-1; c++)
printf("*");

printf("\n");
}

space = 1;

for (k = 1; k <= n – 1; k++)
{
for (c = 1; c <= space; c++)
printf(" ");

space++;

for (c = 1 ; c <= 2*(n-k)-1; c++)
printf("*");

printf("\n");
}

return 0;
}

c program for prime number

Prime number program in c: c program for prime number, this code prints prime numbers using c programming language. To check

whether a number is prime or not see another code below. Prime number logic: a number is prime if it is divisible only by one

and itself. Remember two is the only even and also the smallest prime number. First few prime numbers are 2, 3, 5, 7, 11, 13,

17….etc. Prime numbers have many applications in computer science and mathematics. A number greater than one can be

factorized into prime numbers, For example 540 = 22*33*51
Prime number program in c language

#include

main()
{
int n, i = 3, count, c;

printf(“Enter the number of prime numbers required\n”);
scanf(“%d”,&n);

if ( n >= 1 )
{
printf(“First %d prime numbers are :\n”,n);
printf(“2\n”);
}

for ( count = 2 ; count <= n ; )
{
for ( c = 2 ; c <= i – 1 ; c++ )
{
if ( i%c == 0 )
break;
}
if ( c == i )
{
printf("%d\n",i);
count++;
}
i++;
}

return 0;
}

There are many logic to check prime numbers, one given below is more efficient then above method.
for ( c = 2 ; c <= (int)sqrt(n) ; c++ )
//only checking from 2 to square root of number is sufficient.

There are many more efficient logic then written above.
C program for prime number or not

#include

main()
{
int n, c = 2;

printf(“Enter a number to check if it is prime\n”);
scanf(“%d”,&n);

for ( c = 2 ; c <= n – 1 ; c++ )
{
if ( n%c == 0 )
{
printf("%d is not prime.\n", n);
break;
}
}
if ( c == n )
printf("%d is prime.\n", n);

return 0;
}

C program for prime number using function

#include

int check_prime(int);

main()
{
int n, result;

printf(“Enter an integer to check whether it is prime or not.\n”);
scanf(“%d”,&n);

result = check_prime(n);

if ( result == 1 )
printf(“%d is prime.\n”, n);
else
printf(“%d is not prime.\n”, n);

return 0;
}

int check_prime(int a)
{
int c;

for ( c = 2 ; c <= a – 1 ; c++ )
{
if ( a%c == 0 )
return 0;
}
if ( c == a )
return 1;
}

armstrong number c program

armstrong number c program: c programming code to check whether a number is armstrong or not. A number is armstrong if the

sum of cubes of individual digits of a number is equal to the number itself. For example 371 is an armstrong number as 33 +

73 + 13 = 371. Some other armstrong numbers are: 0, 1, 153, 370, 407.
C programming code

#include

main()
{
int number, sum = 0, temp, remainder;

printf(“Enter a number\n”);
scanf(“%d”,&number);

temp = number;

while( temp != 0 )
{
remainder = temp%10;
sum = sum + remainder*remainder*remainder;
temp = temp/10;
}

if ( number == sum )
printf(“Entered number is an armstrong number.”);
else
printf(“Entered number is not an armstrong number.”);

return 0;
}

c program to generate and print armstrong numbers

armstrong number in c: This program prints armstrong number. In our program we ask the user to enter a number and then we use

a loop from one to the entered number and check if it is an armstrong number and if it is then the number is printed on the

screen. Remember a number is armstrong if the sum of cubes of individual digits of a number is equal to the number itself.

For example 371 is an armstrong number as 33 + 73 + 13 = 371. Some other armstrong numbers are 0, 1, 153, 370, 407.
C code

#include
#include

main()
{
int r;
long number = 0, c, sum = 0, temp;

printf(“Enter the maximum range upto which you want to find armstrong numbers “);
scanf(“%ld”,&number);

printf(“Following armstrong numbers are found from 1 to %ld\n”,number);

for( c = 1 ; c <= number ; c++ )
{
temp = c;
while( temp != 0 )
{
r = temp%10;
sum = sum + r*r*r;
temp = temp/10;
}
if ( c == sum )
printf("%ld\n", c);
sum = 0;
}

getch();
return 0;
}

Fibonacci series in c

Fibonacci series in c programming: c program for Fibonacci series without and with recursion. Using the code below you can

print as many number of terms of series as desired. Numbers of Fibonacci sequence are known as Fibonacci numbers. First few

numbers of series are 0, 1, 1, 2, 3, 5, 8 etc, Except first two terms in sequence every other term is the sum of two previous

terms, For example 8 = 3 + 5 (addition of 3, 5). This sequence has many applications in mathematics and Computer Science.
Fibonacci series in c using for loop

/* Fibonacci Series c language */
#include

main()
{
int n, first = 0, second = 1, next, c;

printf(“Enter the number of terms\n”);
scanf(“%d”,&n);

printf(“First %d terms of Fibonacci series are :-\n”,n);

for ( c = 0 ; c < n ; c++ )
{
if ( c <= 1 )
next = c;
else
{
next = first + second;
first = second;
second = next;
}
printf("%d\n",next);
}

return 0;
}

Output of program:
Fibonacci series program

Fibonacci series program in c using recursion

#include

int Fibonacci(int);

main()
{
int n, i = 0, c;

scanf(“%d”,&n);

printf(“Fibonacci series\n”);

for ( c = 1 ; c <= n ; c++ )
{
printf("%d\n", Fibonacci(i));
i++;
}

return 0;
}

int Fibonacci(int n)
{
if ( n == 0 )
return 0;
else if ( n == 1 )
return 1;
else
return ( Fibonacci(n-1) + Fibonacci(n-2) );
}

linear search in c

Linear search in c programming: The following code implements linear search ( Searching algorithm ) which is used to find

whether a given number is present in an array and if it is present then at what location it occurs.It is also known as

sequential search. It is very simple and works as follows: We keep on comparing each element with the element to search until

the desired element is found or list ends. Linear search in c language for multiple occurrences and using function.
Linear search c program

#include

main()
{
int array[100], search, c, number;

printf(“Enter the number of elements in array\n”);
scanf(“%d”,&number);

printf(“Enter %d numbers\n”, number);

for ( c = 0 ; c < number ; c++ )
scanf("%d",&array[c]);

printf("Enter the number to search\n");
scanf("%d",&search);

for ( c = 0 ; c < number ; c++ )
{
if ( array[c] == search ) /* if required element found */
{
printf("%d is present at location %d.\n", search, c+1);
break;
}
}
if ( c == number )
printf("%d is not present in array.\n", search);

return 0;
}

C program for binary search
Output of code:
Linear Search program output
Linear search for multiple occurrences

In the code below we will print all the locations at which required element is found and also the number of times it occur in

the list.

#include

main()
{
int array[100], search, c, n, count = 0;

printf(“Enter the number of elements in array\n”);
scanf(“%d”,&n);

printf(“Enter %d numbers\n”, n);

for ( c = 0 ; c < n ; c++ )
scanf("%d",&array[c]);

printf("Enter the number to search\n");
scanf("%d",&search);

for ( c = 0 ; c < n ; c++ )
{
if ( array[c] == search )
{
printf("%d is present at location %d.\n", search, c+1);
count++;
}
}
if ( count == 0 )
printf("%d is not present in array.\n", search);
else
printf("%d is present %d times in array.\n", search, count);

return 0;
}

Output of code:
Linear Search program output for multiple occurence

C program for linear search using function

#include

int linear_search(int*, int, int);

main()
{
int array[100], search, c, n, position;

printf(“Enter the number of elements in array\n”);
scanf(“%d”,&n);

printf(“Enter %d numbers\n”, n);

for ( c = 0 ; c < n ; c++ )
scanf("%d",&array[c]);

printf("Enter the number to search\n");
scanf("%d",&search);

position = linear_search(array, n, search);

if ( position == -1 )
printf("%d is not present in array.\n", search);
else
printf("%d is present at location %d.\n", search, position+1);

return 0;
}

int linear_search(int *pointer, int n, int find)
{
int c;

for ( c = 0 ; c < n ; c++ )
{
if ( *(pointer+c) == find )
return c;
}

return -1;
}

C program for binary search

C program for binary search: This code implements binary search in c language. It can only be used for sorted arrays, but

it's fast as compared to linear search. If you wish to use binary search on an array which is not sorted then you must sort

it using some sorting technique say merge sort and then use binary search algorithm to find the desired element in the list.

If the element to be searched is found then its position is printed.
The code below assumes that the input numbers are in ascending order.
C programming code for binary search

#include

main()
{
int c, first, last, middle, n, search, array[100];

printf(“Enter number of elements\n”);
scanf(“%d”,&n);

printf(“Enter %d integers\n”, n);

for ( c = 0 ; c < n ; c++ )
scanf("%d",&array[c]);

printf("Enter value to find\n");
scanf("%d",&search);

first = 0;
last = n – 1;
middle = (first+last)/2;

while( first <= last )
{
if ( array[middle] last )
printf(“Not found! %d is not present in the list.\n”, search);

return 0;
}

c program for bubble sort

c program for bubble sort: c programming code for bubble sort to sort numbers or arrange them in ascending order. You can

easily modify it to print numbers in descending order.
Bubble sort algorithm in c

/* Bubble sort code */

#include

int main()
{
int array[100], n, c, d, swap;

printf(“Enter number of elements\n”);
scanf(“%d”, &n);

printf(“Enter %d integers\n”, n);

for (c = 0; c < n; c++)
scanf("%d", &array[c]);

for (c = 0 ; c < ( n – 1 ); c++)
{
for (d = 0 ; d array[d+1]) /* For decreasing order use < */
{
swap = array[d];
array[d] = array[d+1];
array[d+1] = swap;
}
}
}

printf("Sorted list in ascending order:\n");

for ( c = 0 ; c < n ; c++ )
printf("%d\n", array[c]);

return 0;
}

Bubble sort in c language using function

#include

void bubble_sort(long [], long);

int main()
{
long array[100], n, c, d, swap;

printf(“Enter number of elements\n”);
scanf(“%ld”, &n);

printf(“Enter %ld longegers\n”, n);

for (c = 0; c < n; c++)
scanf("%ld", &array[c]);

bubble_sort(array, n);

printf("Sorted list in ascending order:\n");

for ( c = 0 ; c < n ; c++ )
printf("%ld\n", array[c]);

return 0;
}

void bubble_sort(long list[], long n)
{
long c, d, t;

for (c = 0 ; c < ( n – 1 ); c++)
{
for (d = 0 ; d list[d+1])
{
/* Swapping */

t = list[d];
list[d] = list[d+1];
list[d+1] = t;
}
}
}
}

Matrix multiplication in c

Matrix multiplication in c language: c program to multiply matrices (two dimensional array), this program multiplies two

matrices which will be entered by the user. Firstly user will enter the order of a matrix. If the entered orders of two

matrix is such that they can’t be multiplied then an error message is displayed on the screen. You have already studied the

logic to multiply them in Mathematics. Matrices are frequently used while doing programming and are used to represent graph

data structure, in solving system of linear equations and many more.
Matrix multiplication in c language

#include

int main()
{
int m, n, p, q, c, d, k, sum = 0;
int first[10][10], second[10][10], multiply[10][10];

printf(“Enter the number of rows and columns of first matrix\n”);
scanf(“%d%d”, &m, &n);
printf(“Enter the elements of first matrix\n”);

for ( c = 0 ; c < m ; c++ )
for ( d = 0 ; d < n ; d++ )
scanf("%d", &first[c][d]);

printf("Enter the number of rows and columns of second matrix\n");
scanf("%d%d", &p, &q);

if ( n != p )
printf("Matrices with entered orders can't be multiplied with each other.\n");
else
{
printf("Enter the elements of second matrix\n");

for ( c = 0 ; c < p ; c++ )
for ( d = 0 ; d < q ; d++ )
scanf("%d", &second[c][d]);

for ( c = 0 ; c < m ; c++ )
{
for ( d = 0 ; d < q ; d++ )
{
for ( k = 0 ; k < p ; k++ )
{
sum = sum + first[c][k]*second[k][d];
}

multiply[c][d] = sum;
sum = 0;
}
}

printf("Product of entered matrices:-\n");

for ( c = 0 ; c < m ; c++ )
{
for ( d = 0 ; d < q ; d++ )
printf("%d\t", multiply[c][d]);

printf("\n");
}
}

return 0;
}

String length

This program prints length of string, for example consider the string "c programming" it's length is 13. Null character is

not counted when calculating string length. To find string length we use strlen function of string.h.
C program to find string length

#include
#include

main()
{
char a[100];
int length;

printf(“Enter a string to calculate it’s length\n”);
gets(a);

length = strlen(a);

printf(“Length of entered string is = %d\n”,length);

return 0;
}

String length program executable.

Output of program:
string length

You can also find string length using pointer or without strlen function. Following program shows how to achieve this.
C program to find string length without strlen

C program to find length of a string using pointers.

#include

main()
{
char array[100], *pointer;
int length = 0;

printf(“Enter a string\n”);
gets(array);

pointer = array;

while(*(pointer+length))
length++;

printf(“Length of entered string = %d\n”,length);

return 0;
}

Function to find string length

int string_length(char *s)
{
int c = 0;

while(*(s+c))
c++;

return c;
}

c program to compare two strings

This c program compares two strings using strcmp, without strcmp and using pointers. For comparing strings without using

library function see another code below.
C program to compare two strings using strcmp

#include
#include

main()
{
char a[100], b[100];

printf(“Enter the first string\n”);
gets(a);

printf(“Enter the second string\n”);
gets(b);

if( strcmp(a,b) == 0 )
printf(“Entered strings are equal.\n”);
else
printf(“Entered strings are not equal.\n”);

return 0;
}

C program to compare two strings without using strcmp

Here we create our own function to compare strings.

int compare(char a[], char b[])
{
int c = 0;

while( a[c] == b[c] )
{
if( a[c] == ” || b[c] == ” )
break;
c++;
}
if( a[c] == ” && b[c] == ” )
return 0;
else
return -1;
}

C program to compare two strings using pointers

In this method we will make our own function to perform string comparison, we will use character pointers in our function to

manipulate string.

#include

int compare_string(char*, char*);

main()
{
char first[100], second[100], result;

printf(“Enter first string\n”);
gets(first);

printf(“Enter second string\n”);
gets(second);

result = compare_string(first, second);

if ( result == 0 )
printf(“Both strings are same.\n”);
else
printf(“Entered strings are not equal.\n”);

return 0;
}

int compare_string(char *first, char *second)
{
while(*first==*second)
{
if ( *first == ” || *second == ” )
break;

first++;
second++;
}
if( *first == ” && *second == ” )
return 0;
else
return -1;
}

c program to concatenate strings

This program concatenates strings, for example if the first string is “c ” and second string is “program” then on

concatenating these two strings we get the string “c program”. To concatenate two strings we use strcat function of string.h,

to concatenate without using library function see another code below which uses pointers.
C code

#include
#include
#include

main()
{
char a[100], b[100];

printf(“Enter the first string\n”);
gets(a);

printf(“Enter the second string\n”);
gets(b);

strcat(a,b);

printf(“String obtained on concatenation is %s\n”,a);

getch();
return 0;
}

string concatenation.

Output:

string concatenation

String concatenation without strcat

#include

void concatenate_string(char*, char*);

main()
{
char original[100], add[100];

printf(“Enter source string\n”);
gets(original);

printf(“Enter string to concatenate\n”);
gets(add);

concatenate_string(original, add);

printf(“String after concatenation is \”%s\”\n”, original);

return 0;
}

void concatenate_string(char *original, char *add)
{
while(*original)
original++;

while(*add)
{
*original = *add;
add++;
original++;
}
*original = ”;
}

C programming code using rand

#include
#include

int main() {
int c, n;

printf(“Ten random numbers in [1,100]\n”);

for (c = 1; c <= 10; c++) {
n = rand()%100 + 1;
printf("%d\n", n);
}

return 0;
}

C programming code using random function(Turbo C compiler only)

#include
#include
#include

main()
{
int n, max, num, c;

printf(“Enter the number of random numbers you want “);
scanf(“%d”,&n);

printf(“Enter the maximum value of random number “);
scanf(“%d”,&max);

printf(“%d random numbers from 0 to %d are :-\n”,n,max);
randomize();

for ( c = 1 ; c <= n ; c++ )
{
num = random(max);
printf("%d\n",num);

}

getch();
return 0;
}

cplusplus on line tutorials

lab manuals download


http://technolamp.blogspot.in/p/jntu-lab-manuals-for-cse-it-ece-and-eee.html

http://www.filecrhttp://www.filecrop.com/lab-manual-for-data-structure.htmlop.com/lab-manual-for-data-structure.html

http://www.estudiez.com/index.php?estudiez=temp&ctg=lesson_info&courses_ID=417

Click to access dsa_4.pdf

http://www.scribd.com/doc/62908264/Data-Structure-and-Algorithm-Lab-Manual

Community Lord KARUPPUSAMY Aliases


Arul migu Manthai Sudalaimada Swamy Thiru kovil, MathagaNeri,Vadakkankulam
Arul migu otha pannai sudalaimadan thiru kovil, sirumallange,vallioor
Arul migu massana samy, pallavillai,thirunel velli dist
Arul migu Vallanattu Karuppasamy .
Arul migu Pathinettampadiyan(18-steps Karuppa samy) In Alagar Kovil & Sabari Malai.
Arul migu maarnattu sinnan karuppa samy kannanore, chellampatti taluk, madurai.
Arul migu Santhana Karuppanna samy
Arul migu Periya Karuppasamy
Arul migu Sinna Karuppasamy
Arul migu paalpaarai muthu karuppa samy kannanore, chellampatti taluk, madurai.
Arul migu mayana karuppa samy kannanore, chellampatti taluk, madurai.
Arul migu patta karuppa samy kannanore, chellampatti taluk, madurai.
Arul migu Karadaiyan samy, Thungapuram
Arul migu Ondi Karuppannasamy of sholanganallur,Tiruchi
Arul migu Kaattu Karuppar
Arul migu Karuppu Samy
Arul migu Aaladi Karuppanna Samy
Arul migu Puliyadi Karuppana Samy
Arul migu kaaraiyadi sinna karuppa samy kannanore, chellampatti taluk, madurai.
Arul migu Karuppanaar Samy
Arul migu Karuppanar
Arul migu vetta karuppar
Arul migu Kulla Karuppanaar
Arul migu Sangili Karuppan
Arul migu Sonai Karuppasamy
Arul migu Munnodi Karuppasamy
Arul migu Man malai Karuppasamy
Arul migu Perungkaadu Karuppa samy
Arul migu Ponnuveriyan Karuppa samy
Arul migu Kottai Karupa samy
Arul migu Nondi Karupa samy
Arul migu Nambaga Karupasamy
Arul migu Madai Karuppasamy
Arul migu Vaya Karuppasamy
Arul migu Sappaani Karuppar
Arul migu Moodupaarai Karuppanna Samy
Arul migu kunankarupar kallal(via),kellakoddai,sivagangai
Arul migu Nondi samy
Arul migu Thoppu Karuppasamy
Arul migu Killi kundu Karuppasamy
Sri Malayala Karuppayya
Arul migu Kallan kallachi Karuppasamy perambalur dt nakkasalem village
Arul migu karupannaswamy alayam Ukkadai Ammapet Thanjavur Dt (Rajkumar)9443587492
Thungane Pudhu Karrupu (Near to Ranjankudi Fort -> Ranjankudi Fort is located 17 K.Ms. North of Perambalur,8 km from Tholudur.)

« Older entries