Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Thesis

Data structure and algorithms

Rating
-
Sold
-
Pages
1
Uploaded on
24-02-2023
Written in
2022/2023

In this 3rd lecture, we will learn the syntax of conditional statements in CPP. We will make a simple program , where we will ask computer to print A if A is bigger than B , else print B. Coding Ninjas has supported us in providing this free DSA course. If you are given a number A , and you are told that print +ve if A is positive, otherwise, print not +ve. If a block is not executed, then 'else ' block will be executed. If A is 5 , then 'if A is -2 and if a is -5, then it will print anything. If I enter -5 , then it did n't print anything because if block was not executed this time. But if I add a 'else' block here, then this block is executed. Cin. get ( ) takes input in the form of characters. It took ' 1 ' as a character but we are assigning this value to an integer so that 's why it printed ASCII value of that character. Cin do n't read SPACE , TAB , ENTER and TAB. But we have an another method to take input. Let 's code that tells us which number is greater. If ( a 0) { print +ve } else { if ( a 0 ) { print negative } , otherwise print 0 } } Let 's run it again. Entered A as 15 It printed A is positive This time I entered -1. A is negative. Correct output. We solved it using loop using loop to understand loops clearly. You just have to enter a condition and the statements which you want to execute. You can check your answer by applying this formula Bhaiya. Here is your homework question. Q1- Find sum of all even numbers from 1 to N. We have to tell whether n is prime or not prime number is a number which has only 1 and N as it 's factor We will use this % operator for this question. % tells us remainder when we divide 2 numbers. If any of these numbers gave modules as 0, then N is not prime. If no such number exists, then it is a prime number. We will run a loop from 1 to n , ( for all rows ) We declared a variable i to keep the track of the row number and then we are simply printing star in each column Then we wrote this cout endl , to come to a new line , and after that this code will get executed for every row. We will do many patterns problems in the next video. We will code this triangular figure also in next video. But first let 's understand this code. We will run a loop from 1 to n , ( for all rows ) Then we declared a variable J for columns. J will also run from 1- N and we simply have to print the row number. Then we incremented J inside the column loop and Incrementing i inside the row loop after printing ENTER.

Show more Read less
Institution
Course

Content preview

https://youtu.be/t6zLJOCVqD0 Summarize



Lecture 2: Write Your First
Program in C++
CodeHelp - by Babbar



This is the 2nd lecture of our DSA series.
We will see how a program runs and what
does each line mean in this lecture. This
is how the compilation process work So it
is compiler which makes it possible for us
to run a source code. Coding Ninjas has
supported us in providing this amazing
DSA course to you. Courses are available
in both Hindi and English. you need an
IDE to write, run and execute a code.
There are many IDEs out there -
CodeBlocks, VsCode and many more -
which you do n't even need to install
Replit is one of them. You can directly
create a C++ there and run it using Replit.
In C++, many namespaces are there

Written for

Course

Document information

Uploaded on
February 24, 2023
Number of pages
1
Written in
2022/2023
Type
THESIS
Supervisor(s)
Unknown
Year
Unknown

Subjects

$8.49
Get access to the full document:

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Get to know the seller
Seller avatar
lokeshchhabada

Get to know the seller

Seller avatar
lokeshchhabada Mansarovar Global university
Follow You need to be logged in order to follow users or courses
Sold
-
Member since
3 year
Number of followers
0
Documents
2
Last sold
-

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions