Lets Start With First Code

Dear Sciaku Learner you are not logged in or not enrolled in this course.

Please Click on login or enroll now button.

If you have any query feel free to chat us!

Happy Coding! Happy Learning!

Lecture 1:- Lets Start With First Code

Let's write a simple C++ program that takes two numbers as input and prints their sum. This is the equivalent of the previous Python program but in C++.

cpp

#include <iostream> using namespace std; int main() { // Declare variables to store the input numbers and the result int a, b, result; // Read two integers from input cin >> a >> b; // Calculate the sum of the two numbers result = a + b; // Print the result cout << result << endl; return 0; }

Explanation:

We include the <iostream> header to use input and output operations in C++.

In the main() function, we declare three integer variables: a, b, and result.

We use cin to read two integers from the user, storing them in variables a and b.

We calculate the sum of a and b and store it in the variable result.

Finally, we use cout to print the value of result as the output. The << endl is used to move to the next line after printing the result.

When you run this C++ program and input two integers, it will display their sum as the output, just like the Python program.

For example, if you input:

3 5

The program will output:

8

Remember to compile and run the C++ program using a C++ compiler such as g++ or Visual Studio C++ compiler. Happy coding! If you have any more questions or need further assistance, feel free to ask.

1. Prerequisites

2 Comments

@princesk118
princesk118 Aug 1, 2024 at 10:10 PM

please fix the problem then i will buy it

@vs7977722
vs7977722 Oct 17, 2023 at 10:37 PM

From dynamic programming 2 I'm not able to see any of the videos what to do??

@na3744
na3744 Mar 13, 2024 at 2:03 AM

same here

Frequently Asked Questions About Sciaku Courses & Services

Quick answers to common questions about our courses, quizzes, and learning platform

Didn't find what you're looking for?

help_center Contact Support