Archive for the ‘C’ Category

Swapping a Number

SWAPPING WITHOUT TEMP:

#include <stdio.h>;
 
void main()
{
int a=20,b=30;
a=a+b;
b=a-b;
a=a-b;
printf("a=%d",a);
printf("b=%d",b);
}

SWAPPIG WITH TEMP:

#include <stdio.h>;
void main()
{
int a=20,b=30,temp;
temp=a;
a=b;
b=temp;
printf("a=%d",a);
printf("b=%d",b);
}

Popularity: 1% [?]

Palindrome For String And Numbers

Palindrome Checking Using C:

#include <stdio.h>
#include <conio.h>
#include <string.h>
#define size 26
 
void main()
{
char strsrc[size];
char strtmp[size];
printf("\n Enter String:= ");
gets(strsrc);
strcpy(strtmp,strsrc);
strrev(strtmp);
if(strcmp(strsrc,strtmp)==0)
printf("\n Entered string \"%s\" ispalindrome",strsrc);
else
printf("\n Entered string \"%s\" is not palindrome",strsrc);
getch();
}

Popularity: 1% [?]

Designed by: Business Web Hosting | Thanks to Buy Icons, travel tips and Used Cars