User talk:Prasadshah

PROGRAMMING IN C

BASIC CONCEPTS RELATED TO PROGRAMMING

a. Structure of C Programming. /***********************************************/ 1.Header Files eg.   #include

2.Define Constant                /*Optional*/ eg.   #define MAX 10

3.Function Declaration           /*Optional*/ eg.   void display;

4.Main Method Declaration eg.   void main {         /*body of main function*/ }

4.Body of Main eg.  void main {        /*Data Declaration*/ eg.           int a;

/*Data Initialization*/ eg.            a=5; /*Clear the Screen*/ eg.             clrscr;

/*Body*/ eg.            printf("Hiiiiiiiii"); /*Close the Console Screen*/ eg.            getch; }

1.Simple Program to Print Data void main {     printf("\n HIIIIIIIIIIIII"); getch; } /* Output:- HIIIIIIIIIIIII
 * 1) include
 * 2) include

2.Calculating Sum of Two Numbers. void main {     int n1,n2,sum; sum=0; clrscr; printf("\n Enter Two Numbers= "); scanf("%d %d",&n1,&n2); sum=n1+n2; printf("\n Sum of Two Number is %d",sum); getch; } /* Output:- Enter Two Numbers=3 2 Sum of Two Number is 5
 * 1) include
 * 2) include

3. Swapping of Two Numbers. void main {     int n1,n2,temp; temp=0; clrscr; printf("\n Enter Two Numbers= "); scanf("%d %d",&n1,&n2); printf("\n n1=%d n2=%d",n1,n2); /*Swapping Logic*/ temp = n1; n1 = n2; n2 = temp; printf("\n After Swapping"); printf("\n n1=%d n2=%d",n1,n2); getch; } /* Output:- Enter Two Numbers=5 6 n1=5 n2=6 After Swapping n1=6 n2=5
 * 1) include
 * 2) include