ALLInterview.com :: Home Page KalAajKal.com
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
tip   SiteMap shows list of All Categories in this site.
Google
 
Categories  >>  Software  >>  Programming Languages  >>  C
 
 


 

 
 C interview questions  C Interview Questions
 C++ interview questions  C++ Interview Questions
 VC++ interview questions  VC++ Interview Questions
 Delphi interview questions  Delphi Interview Questions
 Programming Languages AllOther interview questions  Programming Languages AllOther Interview Questions
Question
plz answer.. a program that takes a string e.g. "345" and 
returns integer 345
 Question Submitted By :: 001
I also faced this Question!!     Rank Answer Posted By  
 
  Re: plz answer.. a program that takes a string e.g. "345" and returns integer 345
Answer
# 1
int f(char s[])
{
     int num=0,i;
     for(int i=0;s[i]>='0' && s[i]<='9';i++)
           n=10*n+(s[i]-'0');
     if(i<sizeof(s))
     {
           printf("Error String");
           return 0;
     }
     return n;
{
 
Is This Answer Correct ?    3 Yes 0 No
Ramu
 
  Re: plz answer.. a program that takes a string e.g. "345" and returns integer 345
Answer
# 2
#include<stdio.h>
#include<conio.h>
#include<string.h>
int fun(char *,int);
void main()
{
long int c,l;
char a1[20];
printf("enter the numerical string :");
scanf("%s",&a1);
l=strlen(a1);
c=fun(a,l);
printf("\n%ld",l);
getch();
}
int fun(char *a,long int l1)
{
long int a1[]=
{1,10,100,1000,10000,100000,1000000,10000000,100000000},c;
int p=a1[l1-1],c=0;
for(int i=0;a[i]!='\0';i++)
{
y=((int)a[i])*p;             /*TYPE CASTING*/
c=c+y;
p=p/10;
}
return c;
}
 
Is This Answer Correct ?    1 Yes 2 No
Vignesh1988i
 
 
 
  Re: plz answer.. a program that takes a string e.g. "345" and returns integer 345
Answer
# 3
#include<stdio.h>
#include<stdlib.h>

int main()
{
  char str[10];
  printf("Enter the string : ");
  gets(str);
  printf("Converted integer : %d",atoi(str));
  getchar();
}
 
Is This Answer Correct ?    1 Yes 0 No
Swapnil Chhajer
 

 
 
 
Other C Interview Questions
 
  Question Asked @ Answers
 
Program to find the absolute value of given integer using Conditional Operators N-Tech2
let's take a code struct FAQ { int a; char b; float c; double d; int a[10]; }*temp; now explain me how the memory will be allocated for the structure FAQ and what address will be in the structure pointer (temp)....................  7
Which of the following about automatic variables within a function is correct ? a.its type must be declared before using the variable b.they are local c.they are not initialised to zero d.they are global. TCS3
i=20,k=0; for(j=1;j<i;j=1+4*(i/j)) { k+=j<10?4:3; } printf("%d", k); HCL6
How would you write qsort?  1
How can I call a function, given its name as a string? ABC-Telecom2
main() { printf("\n %d %d %d",sizeof('3'),sizeof("3"),sizeof(3)); } wat is the o/p and how?  7
parkside's triangle.. create a program like this.. enter the size: 6 enter the seed: 1 output: 1 23 456 7891 23456 789123 sample2: enter the size: 5 enter the seed: 3 output: 3 45 678 9123 45678 parkside should not exceed 10 while its seed should only be not more than 9..  4
What is encapsulation?  1
C passes By value or By reference? Geometric-Software5
write a programe returns the number of times the character appears in the string  1
What is the real difference between arrays and pointers?  11
what is the code for getting the output as * ** *** Caritor5
Write a program to find the given number is odd or even without using any loops(if,for,do,while)  2
The C language terminator is a.semicolon b.colon c.period d.exclamation mark TCS3
What is a class?  2
What is RAM memory? and What is ROM?Who designed one is temparary and another is permanent?why they designed like that?By using far pointer which type data(whether hexadecimal)we can access? Excel1
#include <stdio.h> int main ( int argc, char* argv [ ] ) { int value1 = 10; int value2 = 5; printf ( "\n The sum is :%d", value1 | value2 ); } This is the answer asked by some one to add two numbers with out using arithmetic operator?Yes this answer is write it given out put as 15.But how????? what is need of following line? int main ( int argc, char* argv [ ] ) how it work?what is the meaning for this line? please explain me.Advance thanks Excel4
what is the advantage of using SEMAPHORES to ORDINARY VARIABLES??? NSN1
is compiler do read the data line by line or not. ?? LG-Soft3
 
For more C Interview Questions Click Here 
 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us interview questions urls   External Links 
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com