# Write a recursive function to convert a character string of digits to.docx

D

Write a recursive function to convert a character string of digits to an integer. Example: convert(â€œ1234â€) returns 1234. Hint: To convert a character to a number, subtract the ASCII value â€˜0â€™ from the character. For example, if the string s has only one character, then the function can return the value s[0] â€“ â€˜0â€™. Solution #include<stdio.h> int strToInt(char[] ); int main(){ char str[10]; int Value; printf(\"Enter any integer as a string: \"); scanf(\"%s\",str); Value = strToInt(str); printf(\"Equivalent integer value: %d\",Value); return 0; } int strToInt(char str[]){ int i=0,sum=0; while(str[i]!=\'\\0\'){ if(str[i]< 48 || str[i] > 57){ printf(\"Unable to convert it into integer.\ \"); return 0; } else{ sum = sum*10 + (str[i] - 48); i++; } } return sum; } .

## Recommended

Write a SIMPLE java program to print out the numbers from 100 to 1- wi.docx by
Write a SIMPLE java program to print out the numbers from 100 to 1- wi.docxdrosa1
31 views2 slides
Write a simple c++ program that computes the value of ex by using the.docx by
Write a simple c++ program that computes the value of ex by using the.docxdrosa1
12 views1 slide
Write a short assembly language module to be used with C++ that rotate.docx by
Write a short assembly language module to be used with C++ that rotate.docxdrosa1
2 views2 slides
Write a short essay- between 400 and 500 words- responding to the assi.docx by
Write a short essay- between 400 and 500 words- responding to the assi.docxdrosa1
3 views1 slide
Write a SELECT statement that returns the LastName and JobTitle of eac.docx by
Write a SELECT statement that returns the LastName and JobTitle of eac.docxdrosa1
6 views1 slide
Write a recursive C function that counts the number of vowels in a str.docx by
Write a recursive C function that counts the number of vowels in a str.docxdrosa1
7 views2 slides

## More from drosa1

Write a query to display the customer last name and city for all custo.docx by
Write a query to display the customer last name and city for all custo.docxdrosa1
3 views2 slides
write a program that reads package weights and calculate the post fee.docx by
write a program that reads package weights and calculate the post fee.docxdrosa1
2 views2 slides
Write a program that takes an input of n and prints the numbers from 1.docx by
Write a program that takes an input of n and prints the numbers from 1.docxdrosa1
2 views2 slides
Write a program to compute the volume V of a cylinder of radius r and (1).docx by
Write a program to compute the volume V of a cylinder of radius r and (1).docxdrosa1
2 views1 slide
Write a program in assembly language that will test PIN #0 of PORTA to.docx by
Write a program in assembly language that will test PIN #0 of PORTA to.docxdrosa1
4 views2 slides
Write a program that uses a dynamic array that contains 5 items of dou (1).docx by
Write a program that uses a dynamic array that contains 5 items of dou (1).docxdrosa1
2 views1 slide

### More from drosa1(20)

Write a query to display the customer last name and city for all custo.docx by drosa1
Write a query to display the customer last name and city for all custo.docx
drosa13 views
write a program that reads package weights and calculate the post fee.docx by drosa1
write a program that reads package weights and calculate the post fee.docx
drosa12 views
Write a program that takes an input of n and prints the numbers from 1.docx by drosa1
Write a program that takes an input of n and prints the numbers from 1.docx
drosa12 views
Write a program to compute the volume V of a cylinder of radius r and (1).docx by drosa1
Write a program to compute the volume V of a cylinder of radius r and (1).docx
drosa12 views
Write a program in assembly language that will test PIN #0 of PORTA to.docx by drosa1
Write a program in assembly language that will test PIN #0 of PORTA to.docx
drosa14 views
Write a program that uses a dynamic array that contains 5 items of dou (1).docx by drosa1
Write a program that uses a dynamic array that contains 5 items of dou (1).docx
drosa12 views
Write a program that calculates the final value of a ten year- \$10-000 (1).docx by drosa1
Write a program that calculates the final value of a ten year- \$10-000 (1).docx
drosa12 views
Write a program that finds the temperature- as an integer - that is th.docx by drosa1
Write a program that finds the temperature- as an integer - that is th.docx
drosa12 views
Write a python program that opens the career-txt file that is included.docx by drosa1
Write a python program that opens the career-txt file that is included.docx
drosa12 views
Write a program that contains and utilizes a function called haltNum(i.docx by drosa1
Write a program that contains and utilizes a function called haltNum(i.docx
drosa12 views
Write a program in MATLAB to implement the algorithm of Gaussian Elimi.docx by drosa1
Write a program in MATLAB to implement the algorithm of Gaussian Elimi.docx
drosa13 views
write a program to calculate the average of six number input by the us.docx by drosa1
write a program to calculate the average of six number input by the us.docx
drosa17 views
Write a program that uses the DrawingPanel to produces the following f.docx by drosa1
Write a program that uses the DrawingPanel to produces the following f.docx
drosa12 views
Write a program in assembly language 8086 not 8085 to find the number.docx by drosa1
Write a program in assembly language 8086 not 8085 to find the number.docx
drosa17 views
write a mips code which pop-ups a confirmation dialog which have yes o.docx by drosa1
write a mips code which pop-ups a confirmation dialog which have yes o.docx
drosa110 views
Write a program in (C or C++ or Java or python) to capture the center.docx by drosa1
Write a program in (C or C++ or Java or python) to capture the center.docx
drosa12 views
write a new equation of the line in slope intercept form parallel to e.docx by drosa1
write a new equation of the line in slope intercept form parallel to e.docx
drosa15 views
Write a program file_max-c that reads a set of integer numbers from a.docx by drosa1
Write a program file_max-c that reads a set of integer numbers from a.docx
drosa13 views
Write a PHP function (write the function only) to dynamically create a.docx by drosa1
Write a PHP function (write the function only) to dynamically create a.docx
drosa13 views
Write a PASCAL program to compare two integers entered from the keyboa.docx by drosa1
Write a PASCAL program to compare two integers entered from the keyboa.docx
drosa155 views

Gopal Chakraborty Memorial Quiz 2.0 Prelims.pptx by
Gopal Chakraborty Memorial Quiz 2.0 Prelims.pptxDebapriya Chakraborty
709 views81 slides
Create a Structure in VBNet.pptx by
Create a Structure in VBNet.pptxBreach_P
80 views8 slides
Pharmaceutical Inorganic Chemistry Unit IVMiscellaneous compounds Expectorant... by
Pharmaceutical Inorganic Chemistry Unit IVMiscellaneous compounds Expectorant...Ms. Pooja Bhandare
166 views45 slides
Classification of crude drugs.pptx by
Classification of crude drugs.pptxGayatriPatra14
104 views13 slides
Mineral nutrition and Fertilizer use of Cashew by
Mineral nutrition and Fertilizer use of CashewAruna Srikantha Jayawardana
52 views107 slides
Relationship of psychology with other subjects. by
Relationship of psychology with other subjects.palswagata2003
77 views16 slides

Create a Structure in VBNet.pptx by Breach_P
Create a Structure in VBNet.pptx
Breach_P80 views
Pharmaceutical Inorganic Chemistry Unit IVMiscellaneous compounds Expectorant... by Ms. Pooja Bhandare
Pharmaceutical Inorganic Chemistry Unit IVMiscellaneous compounds Expectorant...
Ms. Pooja Bhandare166 views
Classification of crude drugs.pptx by GayatriPatra14
Classification of crude drugs.pptx
GayatriPatra14104 views
Relationship of psychology with other subjects. by palswagata2003
Relationship of psychology with other subjects.
palswagata200377 views
AUDIENCE - BANDURA.pptx by iammrhaywood
AUDIENCE - BANDURA.pptx
iammrhaywood131 views
Class 9 lesson plans by TARIQ KHAN
Class 9 lesson plans
TARIQ KHAN53 views
Pharmaceutical Inorganic chemistry UNIT-V Radiopharmaceutical.pptx by Ms. Pooja Bhandare
Ms. Pooja Bhandare120 views
EILO EXCURSION PROGRAMME 2023 by info33492
EILO EXCURSION PROGRAMME 2023
info33492124 views
11.28.23 Social Capital and Social Exclusion.pptx by mary850239
11.28.23 Social Capital and Social Exclusion.pptx
mary850239383 views

### Write a recursive function to convert a character string of digits to.docx

• 1. Write a recursive function to convert a character string of digits to an integer. Example: convert(â€œ1234â€•) returns 1234. Hint: To convert a character to a number, subtract the ASCII value â€˜0â€™ from the character. For example, if the string s has only one character, then the function can return the value s[0] â€“ â€˜0â€™. Solution #include<stdio.h> int strToInt(char[] ); int main(){ char str[10]; int Value; printf("Enter any integer as a string: "); scanf("%s",str); Value = strToInt(str); printf("Equivalent integer value: %d",Value); return 0; } int strToInt(char str[]){ int i=0,sum=0; while(str[i]!='0'){ if(str[i]< 48 || str[i] > 57){ printf("Unable to convert it into integer. "); return 0; } else{ sum = sum*10 + (str[i] - 48);
Current LanguageEnglish
Español
Portugues
Français
Deutsche