Problem Code: COAD02 Problem link is here Problem Name: Simple Sum Contest Name: CodeAdda Practice Contest – 2 (CPC2016) Author: Yatharth Oza (Username: yatharth100) Difficulty: Easy PREREQUISITES: Math Problem: Here One String is given as a input in each test case. Each String contains some Float numbers join by one character ‘e’. You just need to extract all floats and do sum of all numbers and print output which is correct up to 4 decimal places. Explanation: For this problem we can traverse whole input string by putting one by one character in one temporary string and when ‘e’ comes we will stop and then we can convert string to float and add in ‘Sum’ variable which stores current sum of input. At last we can just return the value of ‘Sum’. After each iteration we make temporary string null and Sum value to 0. If you are doing your code in C then you can make approach like this. But, If you are using JAVA or any object oriented language then it provides directly “split(“e”)” function from which you can make given approach directly. Solution:
asked 29 Mar '16, 18:39
