For Developers
Showing posts with label C. Show all posts
Showing posts with label C. Show all posts

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);

}


SWAPPING 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);

}


PALINDROME FOR STRING AND NUMBERS

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();

}