Lab Description:
In this lab we needed to create a program that displays a menu asking the user to perform the following operations like the sum of a number, the product of a number and the exponent of the number using C++ rather than HLA. We needed to define these numbers using factorial integer. Finding the sum definition, the product definition and the exponential definition. We needed to program it using any method either loops, switch case or etc. The program should result a display and the value the program computes it should return to the original menu until it exit.
In my observation between HLA and C++ is that HLA is much difficult to program. C++ is much easier to program than HLA which that’s why I like to program C++ than HLA. The differences between HLA and C++ is that in HLA is much difficult to find errors after you compile the program that sometimes they say a specific error in a line which the error can be in a different like either top or bottom while in C++ is much easier to find the errors after compiling it they tell you specifically where the errors are in the program. Also in HLA the coding of the program is much longer and harder to code using registers while in C++ the coding is shorter and simple to code. The similarities between HLA and C++ is that both programs compile the same way and show the output the same way after compiling it.
Partner: Cesar Manon
Code:
#include using namespace std; int main() { int num,b=0,c; cout<<" Enter 1 for the sum of a number: \n"; cout<<" Enter 2 for the product of a number: \n"; cout<<" Enter 3 for exponential of a number: \n"; cout<>b; switch(b) //The sum of a number case 1: { c=0; cout<>num; for(int a=1;a<=num;a++) { c=c+a; } cout<<" The answer is = "<<c<<endl; break; //The product of a number case 2: c=1; cout<>num; for(int a=1;a<=num;a++) { c=c*a; } cout<<" The answer is = "<<c<<endl; break; //Exponential case 3: c=2; cout<>num; while(num!=0) { c=c*2; num=num-1; } cout<<" The answer is = "<<c<<endl; break; //Exit case 4: return 0; break; default: main(); } }
Screenshots:
0 Responses
Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.