Showing posts with label programming. Show all posts
Showing posts with label programming. Show all posts

Thursday, September 29, 2011

Fahrenheit to centigrade & Centigrade to Fahrenheit


#include<stdio.h>
#include<conio.h>
main()
{
  float fer,cent;
  int a;
  printf("To convert centigrade to fahtenheit type '1'\nTo convert fahtenheit  to centigrade  type '2': ");
  scanf("%d",&a);
  clrscr();
  if(a==1)
  {
                printf("Enter temperature in centigrade:");
                scanf("%f", &cent);
                fer=(1.8*cent)+32;
                printf("\n Fehrenheit equivalent is : %.2f", fer);
  }
                if(a==2)
  {
                printf("Enter temperature in Fehrenheit:");
                scanf("%f", &fer);
                cent=(fer-32)*5/9;
                printf("\n Centigrade equivalent is : %.2f", cent);
  }
}

About Bit & Byte


Bit=(0&1)
 8 Bit                  =1 Byte
1024 Byte          = 1 Kilobyte or 1KB
1024 Kilobyte    = 1 Megabyte or 1MB
1024 Megabyte  = 1 Gigabyte or 1GB
1024 Gigabyte    = 1 Terabyte or 1TB
1024 Terabyte    = 1 Petabyte or 1PB

The classification of programing


There are many types of programing.
According to the level of programing. Programing are three types
i.High-level language
→a)Ada
   b)Modula-2
   c)Pascal
   d)COBOL
   e)FORTRAN
   f)BASIC

ii.Mid-level language
→a) C
    b)FORTH
    c)Macro-Assembler

iii.Low-level language
→a) Assembly

What is program


Program: To process a particular set of data, the computer must be given a set of instruction is called program. These instructions are entered the computer then stored in a portion of computer memory.
When a computer program is executed the following things to happen
1.        A set of information is entered the computer called the input data then it stored in a portion of computer memory.
2.        The input data will processed to produce certain desired results known as the output.
3.        the output data and perhaps the output data will be printed in a sheet of paper of show in the monitor.

How to create a birthday calculator


#include<stdio.h>
main()
{

int pd,pm,py,od,om,oy,nd,nm,ny;

printf("enter the present date example-30 12 2000\n ");
scanf("%d%d%d",&pd,&pm,&py);
printf("enter the date of birth example-\n ");
scanf("%d%d%d",&od,&om,&oy);

if(pd>=od && pm>=om && py>oy)
{
nd=pd-od;
nm=pm-om;
ny=py-oy;
printf("your age is\n years=%d\n months= %d\n days=%d\n",ny,nm,nd);
}
else if(pd<od && pm>om && py>oy)
{
nd=(pd+30)-od;
nm=pm-(om+1);
ny=py-oy;
printf("your age is\n years=%d\n months= %d\n days=%d\n",ny,nm,nd);
}
else if(pd<od && pm==om && py>oy)
{
nd=(pd+30)-od;
nm=(pm+12)-(om+1);
ny=py-(oy+1);
printf("your age is\n years=%d\n months= %d\n days=%d\n",ny,nm,nd);
}
else if(pd<od && pm<om && py>oy)
{
nd=(pd+30)-od;
nm=(pm+12)-(om+1);
ny=py-(oy+1);
printf("your age is\n years=%d\n months= %d\n days=%d\n",ny,nm,nd);
}
else if(pd>od && pm<om && py>oy )
{
nd=pd+od;
nm=(pm+12)-om;
ny=py-(oy+1);
printf("your age is\n years=%d\n months= %d\n days=%d\n",ny,nm,nd);
}

else if(py<oy)
printf("invalid your input    \n INPUT AGAIN");

if(ny>13 && ny<20)
printf("Ohh u r a teen ager");

}

Types of Programming Language


The 12 most widely used languages:
  • C
  • Java
  • C++
  • PHP
  • Visual Basic
  • C#
  • Python
  • Perl
  • JavaScript
  • Embarcadero Delphi
  • Objective-C
  • Ruby

Types of Programming


There are some types of programming
  • Compiler optimization
  • Concurrent programming
  • Declarative programming
  • Event-driven programming
  • Functional programming
  • Imperative programming
  • Literate programming
  • Object-oriented programming
  • Parsing

Programming Language


Different programming languages support different styles of programming (called programming paradigms). The choice of language used is subject to many considerations, such as company policy, suitability to task, availability of third-party packages, or individual preference. Ideally, the programming language best suited for the task at hand will be selected. Trade-offs from this ideal involve finding enough programmers who know the language to build a team, the availability of compilers for that language, and the efficiency with which programs written in a given language execute. Languages form an approximate spectrum from "low-level" to "high-level"; "low-level" languages are typically more machine-oriented and faster to execute, whereas "high-level" languages are more abstract and easier to use but execute less quickly. It is usually easier to code in "high-level" languages than in "low-level" ones.
Allen Downey, in his book How To Think Like A Computer Scientist, writes:
The details look different in different languages, but a few basic instructions appear in just about every language:
·         input: Get data from the keyboard, a file, or some other device.
·         output: Display data on the screen or send data to a file or other device.
·         arithmetic: Perform basic arithmetical operations like addition and multiplication.
·         conditional execution: Check for certain conditions and execute the appropriate sequence of statements.
·         repetition: Perform some action repeatedly, usually with some variation.
Many computer languages provide a mechanism to call functions provided by libraries such as in a .so. Provided the functions in a library follow the appropriate run time conventions (e.g., method of passing arguments), then these functions may be written in any other language.

What is Programming

Computer programming (often shortened to programming or coding) is the process of designing, writing, testing, debugging and maintaining the source code of computer programs. This source code is written in a programming language. The purpose of programming is to create a program that exhibits a certain desired behavior. The process of writing source code often requires expertise in many different subjects, including knowledge of the application domain, specialized algorithms and formal logic.