Community Sites
Create your own community website and start earning today !
It's Free !
 
Communities Members BookmarksPolls Fresher Jobs Funny Pictures MCA Projects New Member FAQ  



My Profile
Active Members
TodayLast 7 Days more...



Awards & Gifts
Online Exams

Fresher Jobs


Our fresher job section is exclusively for fresh graduates! Find jobs for freshers in major Indian cities including Bangalore, Chennai, Hyderabad, Pune or Kochi

Resources


Find educational articles, blogs, discussion threads and other resources.

Colleges


Find details about any college in India or search for courses.

website counter



C Program- convert a string into number


Posted Date: 10 Jun 2008    Resource Type: Articles/Knowledge Sharing    Category: Computer & Technology

Posted By: Girish Patil       Member Level: Diamond
Rating:     Points: 2



/*objective:
convert a string into number
*/

int convert(char *a);
void main()
{
char string[6];
int no;
clrscr();
printf("Enter a string:");
gets(string);
no=convert(string);
if(no!=-1)
{
printf("\n string %s represents no %d",string,no);
}
else
{
printf("\n string %s is invalid",string);
}
getch();
}
int convert(char *a)
{
int i;
int result=0;
for(i=0;a[i]!='\0';i++)
{
if(a[i]>='0' && a[i]<='9')
{
result=result*10+(a[i]-'0');
}
else
{
return -1;
}
}
return result;
}




Responses

Author: Lenin    10 Jun 2008Member Level: Diamond   Points : 2
hi giri are you a computer student , i know only small programs in C.But i know C is a SEA.Am i right ? I remember the days when i used to mugup the codings for Lab exams.still c fear is there.
Also still C is in flying colours


Feedbacks      
Popular Tags   What are tags ?   Search Tags  
(No tags found.)

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: C Program- separate alphabets from one string into another string
Previous Resource: C Program- matrix addition in dynamic way
Return to Discussion Resource Index
Post New Resource
Category: Computer & Technology


Post resources and earn money!
 
Related Resources

Watch TV Channels



Contact Us    Privacy Policy    Terms Of Use   

SpiderWorks Technologies Pvt Ltd. 2006 - 2007 All Rights Reserved.