we all know how to swap numbers in a program..
BUT we use a variable temp/like that to store the initial value..
can the same be done without using a TEMP variable?
sujithtom said:
this is the best way to do it with out using a temp variablecg84 said:
swatkat said:
NikhilVerma said:
cg84 said:
do you have any more of such stuff dude?
#include <iostream.h>
void main()
{
char a[50],b[50];
int j=0;
for(int i=0;i<50;i++)
a[i]=b[i]=0;
cout << "Enter string 1 : ";
cin >> a;
cout << "Enter string 2 : ";
cin >> b;
for(i=0;;i++)
{
if(a[i]=='\0') break;
if(b[i]=='\0') {j=1;
break;}
a[i]=a[i]+b[i];
b[i]=a[i]-b[i];
a[i]=a[i]-b[i];
}
if(j==0)
{
j=i;
do
{
a[i]=b[i];
i++;
}while(b[i]!='\0');
b[j]='\0';
a[i]='\0';
}
else
{
j=i;
do
{
b[i]=a[i];
i++;
}while(a[i]!='\0');
a[j]='\0';
a[i]='\0';
}
cout << "String 1 : "<<a<<endl;
cout << "String 2 : "<<b<<endl;
}
DKant said:
alib_i said:
#include<stdio.h>
#include<conio.h>
void main()
{
FILE *fd;
char c;
clrscr();
fd = fopen("printme.c", "r"); /* Enter the address of the file */
while (!feof(fd))
{
fscanf(fd, "%c", &c);
putchar(c);
}
fclose(fd);
getch();
}
shoegoe said:
alib_i said: