You are currently viewing If-else Statements in C VS Python
IF-Else in c vs python

If-else Statements in C VS Python

Spread the love

We know that decision making is the most important concept of all the programming languages. Condition making is the one of the important aspect of decision making.

Three kind of statements

  1. If statements
  2. If-else statements
  3. Nested if statements

If Statements

The if statements is used to test a specific condition. If condition is true, a block of code (if-block) will be executed.

If-else sttements

The if-else statements is similar to if statement but it also provide the block of the code for the false case of the condition to be checked.

Nested if statements

Looking of statements inside another loops

If Statements in python

Syntax for if statements



if expression:
   Statements

Python code for if statements

num=int(input("Number"))
if num%2==0:
print("Even")

If-else statements in c

IF-Else in c vs python
IF-Else in c vs python

Syntax for if-else statements

if(expression){
//code to be executed
}
#include<stdio.h>
int number;
int main()
{
    printf("Enter the number:\n");
    scanf("%d",&number);
    if(number%2==0){
        printf("This is even number");}
        else printf("This is odd number");
}

In this c program we declared number as a input variable for if else statements. Use simple if else logic to print even or odd number.

Summary:

In this article we saw How to if statements id different for both languages (i.e. c and python)

sachin Pagar

I am Mr. Sachin pagar Embedded software engineer, the founder of Sach Educational Support(Pythonslearning), a Passionate Educational Blogger and Author, who love to share the informative content on educational resources.

Leave a Reply