To compile and execute the program, copy the code into a text file. Save the text file with the extinction .c (ex. program.c). Save your file in turboc2 or borland (it may your othe c-compiler). Now open you IDE (tc.exe) , goto file->pick file. Your source file will be loaded into IDE. Now you can compile and run the file easily.
Swaping of two numbers:
swaping means changing the content of A memory location to B and vice versa. In programing we use a 3rd temporary to change the content.
#include <stdio.h>
#include <conio.h>
main()
{
int a, b, temp;
clrscr();
gotoxy(31,1);
printf("Swaping Of Two Numbers");
gotoxy(26,3);
printf("http:\\techaravind.blogsopt.com");
gotoxy(1,5);
printf("\nEnter any two numbers: ");
scanf("%d %d", &a, &b);
printf("\n\nBefore Swapping:\n");
printf("\na = %d\n", a);
printf("\nb = %d\n", b);
temp = a;
a = b;
b = temp;
printf("\n\nAfter Swapping:\n");
printf("\na = %d\n", a);
printf("\nb = %d\n", b);
getch();
}
0 comments:
Post a Comment