Answer to Question #149108 in C++ for Khan

Question #149108
To find the ratio between Computer science Marks and total obtained marks.Please input computer science marks 80. Please input Obtained Marks in FAS-425. Ration between Two Values =0.1882352
1
Expert's answer
2020-12-06T10:23:15-0500
#include <iostream>
using namespace std;


int main () {
    // we declare a variable for computer science marks
    int computer_science_marks;
    cout << "Enter your marks in Computer Science: ";
    cin >> computer_science_marks;
    
    // we declare a variable for obtained marks
    char obtained_marks[10];
    cout << "Enter your obtained marks: ";
    cin >> obtained_marks;
    
    string number = " ";
    // this is cycle for seperate number in a obtained marks
    for (int i = 0; i < 10; i++) {
        if (isdigit(obtained_marks[i])) {
            number += obtained_marks[i];
        }
    }
    int obtained_marks_integer;
    obtained_marks_integer = stoi(number); 
    
    cout << "the ratio is computer science marks to obtained marks is " << (float) computer_science_marks / obtained_marks_integer;
    return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog