Calculator Tutorial
This tutorial is about a standard library input function of scanf (); how to declare variables, initialize and assign them? how do assignment operators work?
#include <stdio.h>
int main(int argc, char *argv[])
{
int Prl_Num1, Prl_Num2;
int Num1;
scanf("%d,%d",&Prl_Num1,&Prl_Num2);
Num1 = Prl_Num1;
printf("Prl_Num1 = %d,Prl_Num2 = %d\n",Prl_Num1,Prl_Num2);
printf("Prl_Num1 + Prl_Num2 = %d\n", Prl_Num1+Prl_Num2);
printf("Prl_Num1 += Prl_Num2, Prl_Num1 = %d\n", Prl_Num1+=Prl_Num2);
Prl_Num1 = Num1;
printf("Prl_Num1 - Prl_Num2= %d\n", Prl_Num1-Prl_Num2);
printf("Prl_Num1 -= Prl_Num2, Prl_Num1 = %d\n", Prl_Num1-Prl_Num2);
Prl_Num1 = Num1;
printf("Prl_Num1 * Prl_Num2= %d\n", Prl_Num1*Prl_Num2);
printf("Prl_Num1 *= Prl_Num2, Prl_Num1 = %d\n", Prl_Num1*=Prl_Num2);
Prl_Num1 = Num1;
printf("Prl_Num1 / Prl_Num2= %d\n", Prl_Num1/Prl_Num2);
printf("Prl_Num1 /= Prl_Num2, Prl_Num1 = %d\n", Prl_Num1/=Prl_Num2);
Prl_Num1 = Num1;
printf("Prl_Num1 %% Prl_Num2= %d\n", Prl_Num1%Prl_Num2);
printf("Prl_Num1 %%= Prl_Num2, Prl_Num1 = %d\n", Prl_Num1%=Prl_Num2);
return 0;
}
Step 1: create a document called calculator.c
Step 2: input the codes shown above and save it
Step 3: open terminal (Ctl + Alt + T)
Step 4: change directory to where .c is (here is PRL_en_C)
Step 5: g++ -o calculator Calculator.c
Step 6: ./calculator (Your .c document)
Step 7: input two integers like 7,3

