interview questions and answers

Technical Interview Questions | DataStructure Interview Questions

Home interview questions Programming interview questions DataStructure 
Saturday, 11 February 2012
Main Menu
Home
Online Test
Contest
Search
FAQs
Contact Us
Login
Most Popular Category
JAVA

Microsoft Technologies
ASP, C#, DotNet, ...

Programming
C++, PHP, VB, ...

SAP

Testing

Web Technologies

Polls
Does personal networking help in job search?
 
IT Placement Papers interview questions Programming interview questions DataStructure

This category contains DataStructure Interview Questions and Answers


Write a function that takes in a string parameter and checks to see whether or not it is an integer,

PDF Print E-mail


#include <stdio.h>

int strtoint(char *s)
{
int index = 0, flag = 0;

while( *(s+index) != '{xtypo_info}
#include <stdio.h>

int strtoint(char *s)
{
int index = 0, flag = 0;

while( *(s+index) != '\0')
{
if( (*(s + index) >= '0') &&
*(s + index) <= '9')
{
flag = 1;
index++;
}
else
{
flag = 0;
break;
}
}

if( flag == 1 )
return atoi(s);
else
return 0;
}

main()
{
printf("%d",strtoint("0123"));
printf("\n%d",strtoint("0123ii"));
}


{/xtypo_info}')
{
if( (*(s + index) >= '0') &&
*(s + index) <= '9')
{
flag = 1;
index++;
}
else
{
flag = 0;
break;
}
}

if( flag == 1 )
return atoi(s);
else
return 0;
}

main()
{
printf("%d",strtoint("0123"));
printf("\n%d",strtoint("0123ii"));
}






Be first to comment this article

Only registered users can write comments.
Please login or register.

 
< Prev   Next >

Technical Interview Questions | DataStructure Interview Questions

Top!
Top!
Copyright © 2008 InterviewDuniya.com All Rights Reserved.
Partner Site: Maheshwari Matrimony