Showing posts with label Turbo C. Show all posts
Showing posts with label Turbo C. Show all posts
Friday, November 11, 2011
How to check a number palindrome or not in C
How to check a number palindrome or not in C
#include<stdio.h>
void main(){
int n,r,sum=0,temp;
printf("Please enter a number: ");
scanf("%d",&n);
temp=n;
while(n){
r=n%10;
n=n/10;
sum=sum*10+r;
}
if(temp==sum)
printf("%d is a palindrome number",temp);
else
printf("%d is not a palindrome number",temp);
}
Monday, November 7, 2011
Menu Driven Dos program
Simple Your details program in DOS. This is a menu driven program. Try it.
@ECHO off
color 2
cls
:start
ECHO.
ECHO 1. Print Name
ECHO 2. Print Mobile
ECHO 3. Print Address
set choice=
set /p choice=Type the number to print text.
if not '%choice%'=='' set choice=%choice:~0,1%
if '%choice%'=='1' goto op1
if '%choice%'=='2' goto op2
if '%choice%'=='3' goto op3
ECHO "%choice%" is not valid, try again
ECHO.
goto start
:op1
ECHO "Write Your name"
goto end
:op2
ECHO "Write Your mobile number"
goto end
:op3
ECHO "Write your address"
goto end
:end
@ECHO off
color 2
cls
:start
ECHO.
ECHO 1. Print Name
ECHO 2. Print Mobile
ECHO 3. Print Address
set choice=
set /p choice=Type the number to print text.
if not '%choice%'=='' set choice=%choice:~0,1%
if '%choice%'=='1' goto op1
if '%choice%'=='2' goto op2
if '%choice%'=='3' goto op3
ECHO "%choice%" is not valid, try again
ECHO.
goto start
:op1
ECHO "Write Your name"
goto end
:op2
ECHO "Write Your mobile number"
goto end
:op3
ECHO "Write your address"
goto end
:end











