What is this programming language?  C or C++

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

What is this programming language?  C or C++

#include<iostream>|
#include<string.h>
using namespace std;
int charToInt (char ch){ //function to converyt character to integer
if(ch >= '0' && ch <= '9')
1
2
3
4
5
return (int)ch - '0';
6
7
else
8
return (int)ch - 'A' + 10;
}
int toBase10(char *arr){
int n = strlen(arr);
int p = 1;
int result = e;
for (int i = n-1; i >= @; i--){ //reverse traversal of array to right to left
result = result + (charToInt(arr[i]) * p); //finding the result
p = p * 14;
}
return result;
}
int main() //main method
//function to convert into decimal number
//finding the length of char array
10
11
12
13
//to store the result
14 E
15
16
//incrementing the power
17
18
//returning the result
19
20
21 E {
char arr[5][18];
int answer[5];
cout « "Enter 5 numbers in 14th base\n";
for (int i = 0; i < 5; i++){
cin » arr[i];
//calling the function and storeing the result into integer array
answer[i] = toBase1e(arr[i]);
//array to store 14th base numbers
//array to store decimal numbers
22
23
24
25
26
//user input
27
28
29
//printing the result
cout «"Number in 14th Base\tCorresponding Decimal Number\n";
for (int i = e; i <5; i++)
cout «"\t" « arr[i] «"\t\t\t" «answer[i] <«endl;
30
31
32
33
34
return e;
35
}
Transcribed Image Text:#include<iostream>| #include<string.h> using namespace std; int charToInt (char ch){ //function to converyt character to integer if(ch >= '0' && ch <= '9') 1 2 3 4 5 return (int)ch - '0'; 6 7 else 8 return (int)ch - 'A' + 10; } int toBase10(char *arr){ int n = strlen(arr); int p = 1; int result = e; for (int i = n-1; i >= @; i--){ //reverse traversal of array to right to left result = result + (charToInt(arr[i]) * p); //finding the result p = p * 14; } return result; } int main() //main method //function to convert into decimal number //finding the length of char array 10 11 12 13 //to store the result 14 E 15 16 //incrementing the power 17 18 //returning the result 19 20 21 E { char arr[5][18]; int answer[5]; cout « "Enter 5 numbers in 14th base\n"; for (int i = 0; i < 5; i++){ cin » arr[i]; //calling the function and storeing the result into integer array answer[i] = toBase1e(arr[i]); //array to store 14th base numbers //array to store decimal numbers 22 23 24 25 26 //user input 27 28 29 //printing the result cout «"Number in 14th Base\tCorresponding Decimal Number\n"; for (int i = e; i <5; i++) cout «"\t" « arr[i] «"\t\t\t" «answer[i] <«endl; 30 31 32 33 34 return e; 35 }
Expert Solution
steps

Step by step

Solved in 2 steps with 2 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY