Wednesday, October 9, 2013

Bigger Of Two Numbers

#include<stdio.h>
#include<conio.h>
void main()
{
int a,b;
clrscr();
printf("enter two numbers");
scanf("%d%d",&a,&b);
if(a>b)
printf("%d is greater than %d",a,b);
else printf("%d is greater than %d",b,a);
getch();
}

Tuesday, September 24, 2013

C Programming

  C is a general-purpose programming language initially developed by Dennis Ritchie between 1969 and 1973 at AT&T Bell Labs.
  C is one of the most widely used programming languages of all time, and C compilers are available for the majority of available computer architectures and operating systems.
  Many later languages have borrowed directly or indirectly from C, including C#, D, Go, Rust, Java, JavaScript, Limbo, LPC, Objective-C, Perl, PHP, Python, Verilog (hardware description language) and Unix's C shell.


Basic Structure of a C Program is as follows [in order]  :
1.Pre-processor Directives / Header-Files
2.Global-variables
3.Main Function[with-in the main is the local variable declaration and other instructions]
4.Other User defined functions

Note : Every program in C starts executing from the first instruction in the main() and ends with the last instruction in the main().
C Compiles which may be used to compile C programs are : Turbo C, GCC, Dev C, Visual C, Code Blocks ,etc.
Various compilers have minor changes in the compiler-specific commands' syntax[i.e. commands which can be interpreted only by specific compilers like clrscr() to clear screen in Turbo C].

Example C Program :

/* Hello World program */  #include<stdio.h>
  int main()
  {
      printf("Hello World");
      return 0;
  }
next..

Bigger number of two inputs[integer]


#include<stdio.h>         //Standard input/output header
#include<conio.h>        //Console input/output header
int main()                      //the main function
{
int a,b;                       //Integer declaraion
clrscr();                     //clear screen command
printf("Enter two numbers :\n");    //printf to print statement
scanf("%d%d",&a,&b);               //scanf to take in two values
if(a>b)                 //if condition to compare which is bigger
printf("%d is greater than %d",a,b); //if condition is true
else
printf("%d is greater than %d",b,a); //if condition is false
getch();
}