Ads

C vs Python Programming Syntax

for example lets see addition of two numbers

in C,

#include<stdio.h>      // Header File,for prinf() and scanf()
int main()             // main () function. Start of program  
{
   int a, b, c;         // Variable Declaration
   printf("Enter two numbers to add\n");  
   scanf("%d%d", &a, &b);       // getting input from user
   c = a + b;                   // calculation part
   printf("Sum of the numbers = %d\n", c); // showing output to screen
   return 0;
}

O/p:

Addition C program output.

In Python

a = int(input("enter first number: ")) // getting input to a from user
b = int(input("enter second number: ")) // getting input to b from user
sum = a + b // calculation part
print("sum:", sum) // showing output to the user.

O/P:

enter first number:5
enter second number:7
sum: 12

Comments

Popular posts from this blog

Datatypes in C

Ethical Hacking V10

Installing Anaconda on Windows.