Found 34484 Articles for Programming

When to use C over C++, and C++ over C?

Kumar Varma
Updated on 18-Jun-2020 13:05:03

1K+ Views

If you would like an application that works directly with computer hardware or deals with the desktop app development, C++ is an good option. C++ programs include server-side applications, networking, gaming, and even device drivers for your PC. However, if you need to code truly tiny systems, using C will result in less overhead than C++.C++ is well-rounded in terms of platforms and target applications, so if your project is focused on extremely low-level processing, then you may want to use C++. C++ is often used for large-scale, multi-man, complex projects where separate people need to work on modularised components. ... Read More

What is the difference Between C and C++?

Alankritha Ammu
Updated on 10-Feb-2020 11:19:15

836 Views

Following are some of the differences between C and C++.When compared to C++, C is a subset of C++. All valid C programs are valid C++ programs.C is a structural or procedural programming language, while C++ is an object oriented programming language.In C, Functions are the fundamental building blocks, while in C++, Objects are the fundamental building blocks.C doesn't have variable references, while C++ has variable references.C uses malloc and free for memory allocation while C++ uses new and delete for memory allocation.C does not provide direct support for error handling, while C++ supports exception handling that helps in error ... Read More

How to indent multiple if...else statements in Python?

Malhar Lathkar
Updated on 26-Feb-2020 11:11:26

2K+ Views

Use of indented blocks is an important feature of Python. Indent level of the block is more than previous statements. Hence, if multiple if statements are present in a program in nested fashion, each subsequent indented block will have increasing level of indent.if expr1==True:     if expr2==True:         stmt1     else:          if expr3==True:         stmt2 else:     if expr3==True:        stmt3     else:        stmt4

How to indent an if...else statement in Python?

Malhar Lathkar
Updated on 18-Jun-2020 13:04:11

669 Views

One of the characteristic features of Python is use of uniform indent to denote a block of statements. A block is initiated by − symbol As soon as − symbol is typed and enter pressed, any Python aware editor will take cursor to next line with increased indent. All lines entered subsequently will follow same level of indent. To signal end of block, indent level must be reduced by pressing backspace.Using above procedure give − after if statement and write statements in true block. Then dedent by backspace and write else − In another block of increased indent enter statements ... Read More

Can we use pass statement in a Python if clause?

Malhar Lathkar
Updated on 18-Jun-2020 13:01:38

98 Views

In Python, pass keyword is a dummy statement. It is used where a statement is necessary to fulfill syntax requirement but the actual implementation of processing logic is yet to be finalized. It can be used in if as well as else blockif expr==True:    pass else:    pass

Can we use continue statement in a Python if clause?

Malhar Lathkar
Updated on 26-Feb-2020 11:05:28

116 Views

Python's continue statement is a loop control statement. It causes starting next iteration of loop after abandoning current iteration. Invariably is is executed conditionally i.e. in if blockwhile expr==True:     stmt1     stmt2     if expr2==True:        continue     stmt3     stmt4However, it can't be used in an if block if it is not a part of loop. If used, interpreter will throw syntax error.

Can we use break statement in a Python if clause?

Malhar Lathkar
Updated on 26-Feb-2020 11:06:04

131 Views

Python's break keyword is used as decision control statement. It causes the remaining iterations to be abandoned and control of execution goes to next statement after the end of loop. Invariably it is executed conditionally and appears inside if block within a loop.while expr==True:     stmt1         stmt2         if expr2==True:        break     stmt3     stmt4   However it can't be used in an if block if it is not a part of loop. 

How to exit from a Python if clause?

Malhar Lathkar
Updated on 30-Jul-2019 22:30:21

476 Views

It is not possible to exit from an if block of Python code. The break keyword does appear in if block but it has to inside a loop. It is however possible to exit from entire program from inside if block by sys.exit()

What are the good resources to Learn C++?

Syed Javed
Updated on 10-Feb-2020 11:18:33

365 Views

There are many resources on the web that can help you learn C++. I've tried to give you a compiled list of some of the best resources out there to learn C++ −C++ − This is a great place to learn C++ as it covers almost all basic and intermediate topics in C++ in depth and is overall a great resource to learn C++.A Tour of C++ (Bjarne Stroustrup) − The “tour” is a quick tutorial overview of all of standard C++ (language and standard library, and using C++11) at a moderately high level for people who already know C++ ... Read More

What does colon ':' operator do in Python?

Malhar Lathkar
Updated on 18-Jun-2020 12:59:27

8K+ Views

The : symbol is used for more than one purpose in PythonAs slice operator with sequence −The − operator slices a part from a sequence object such as list, tuple or string. It takes two arguments. First is the index of start of slice and second is index of end of slice. Both operands are optional. If first operand is omitted, it is 0 by default. If second is omitted, it is set to end of sequence.>>> a=[1, 2, 3, 4, 5] >>> a[1:3] [2, 3] >>> a[:3] [1, 2, 3] >>> a[2:] [3, 4, 5] >>> s='computer' >>> s[:3] ... Read More

Advertisements