Program:
#include<stdio.h>
#include<conio.h>
#include<string,h>
#include<ctype.h>
main()
{
int i,flag=0,f=0,n=0;
char a[100],c;
do
{
flag=0,f=0;
printf("enter the string:");
scanf("%s",a);
n=strlen(a);
for(i=0;i<n;i++)
{
if(!isdigit(a[i]))
{
if(a[i]==".")
{
if(f==1)
{
flag==1;
}
f=1;
continue;
}
else
flag=1;
break;
}
}
if(flag==0&&f==0)
printf("\n the given string is %s is integer",a);
else
if(flag==0&&f==1)
printf("\n the given string %s is floating point",a);
else
printf("\n the given string %s is not a number",a);
printf("\n want to check another(y/n)");
scanf("%c",&c);
}
while(c='y'/c='n');
}
No comments:
Post a Comment