Professor Porua https://www.professorporua.squaryum.com Squaryum's Educational Guide Thu, 25 Jan 2024 12:25:02 +0000 en-US hourly 1 https://wordpress.org/?v=6.7.1 https://www.professorporua.squaryum.com/wp-content/uploads/2024/01/cropped-Logo-500-32x32.png Professor Porua https://www.professorporua.squaryum.com 32 32 Nested Loop https://www.professorporua.squaryum.com/nested-loop/ Thu, 25 Jan 2024 12:20:31 +0000 https://www.professorporua.squaryum.com/?p=419

C Programming: Chapter 5

Nested Loop

Design 1:

#
##
###
####
#####

#include<conio.h>
#include<stdio.h>
void main()
{
clrscr();
int i,j;
for(i=1;i<=5;i++)
{
for(j=1;j<=i;j++)
{
printf(“#”);
}
printf(“\n”);
}
getch();
}

Design 3:

1
00
111
0000
11111

#include<conio.h>
#include<stdio.h>
void main()
{
clrscr();
int i,j,a;
for(i=1;i<=5;i++)
{
for(j=1;j<=i;j++)
{
a=i%2;
printf(“%d”,a);
}
printf(“\n”);
}
getch();
}

Design 2:

*****
****
***
**
*

#include<conio.h>
#include<stdio.h>
void main()
{
clrscr();
int i,j,a;
for(i=5;i>=1;i–)
{
for(j=1;j<=i;j++)
{
printf(“*”);
}
printf(“\n”);
}
getch();
}

Design 4:

1
10
101
1010
10101

#include<conio.h>
#include<stdio.h>
void main()
{
clrscr();
int i,j,a;
for(i=1;i<=5;i++)
{
for(j=1;j<=i;j++)
{
a=j%2;
printf(“%d”,a);
}
printf(“\n”);
}
getch();
}

]]>
For Loop https://www.professorporua.squaryum.com/for-loop/ Thu, 25 Jan 2024 12:14:09 +0000 https://www.professorporua.squaryum.com/?p=414

C Programming: Chapter 4

For Loop

Print “I love dogs” n times.

#include<conio.h>
#include<stdio.h>
void main()
{
clrscr();
int i,n;
scanf(“%d”,&n);
for(i=1;i<=n;i++)
{
printf(“I love dogs\n”);
}
getch();
}

Print even numbers from 1 to n.

#include<conio.h>
#include<stdio.h>
void main()
{
clrscr();
int i,n;
scanf(“%d,&n);
for(i=2;i<=n;i=i+2)
{
printf(“%d\t”,i);
}
getch();
}

]]>
Simple Interest https://www.professorporua.squaryum.com/simple-interest/ Thu, 25 Jan 2024 11:52:30 +0000 https://www.professorporua.squaryum.com/?p=406

Mathematics: Chapter 3

Simple Interest (SI)

Suppose P is the initial amount (which is lent, deposited, invested or principal), t is the time or tenure & r is rate of interest, then Simple Interest (SI) can be calculated as below:

From the above formula, Principal (P), Rate (r) & Time (t) can be calculated as follows:

And, final Amount (A) can be calculated as:

Example:

Suppose a certain sum of money is deposited at 5% per annum Simple Interest, which amounted to Rs. 50,000 after 10 years. Then the sum of money can be calculated by the following:

Amount = A = Rs. 50,000

Rate = r = 5

Time = t = 10

Therefore, Principal = P = the sum of money = A/(1+((t x r)/100)) = 50000/(1+((10 x 5)/100)) = 50000/(1+(5/10)) = (50000 x 10)/15 = Rs. 33,333.33

and. Simple Interest = SI = A-P = 50000 – 33333.33 = Rs. 16,666.67

]]>
While Loop https://www.professorporua.squaryum.com/while-loop/ Thu, 25 Jan 2024 11:38:24 +0000 https://www.professorporua.squaryum.com/?p=402

C Programming: Chapter 3

While | Do While

While Loop

Main concept

while(condition)
{
statement;
}

Do While Loop

Main concept

do
{
statement;
}
while(condition);

AS LONG AS THE CONDITION IS VALID, THE STATEMENT, INSIDE THE WHILE (OR DO WHILE) LOOP, WILL KEEP ON RUNNING, NO MATTER WHAT THE STATEMENT IS

Print even numbers from 1 to 100.

#include<conio.h>
#include<stdio.h>
void main()
{
clrscr();
int a=2;
while(a<=100)
{
printf(“%d\t”,a);
a=a+2;
}
getch();
}

Print “THIS IS A TEXT” n times using do while.

#include<conio.h>
#include<stdio.h>
void main()
{
clrscr();
int a=1,n;
scanf(“%d”,&n);
do
{
printf(“THIS IS A TEXT\n”);
}
while(a<=n);
getch();
}

\t IS USED FOR 1 TAB

\n IS USED FOR NEW LINE

]]>
If Else https://www.professorporua.squaryum.com/if-else/ Thu, 25 Jan 2024 11:32:08 +0000 https://www.professorporua.squaryum.com/?p=398

C Programming: Chapter 2

If Else

 Expression

Meaning

a==b

a is equal to b

a!=b

a is not equal to b

a<=b

a is less than equal to b

a>=b

a is greater than equal to b

a<b

a is less than b

a>b

a is greater than b

a%b

remainder of a÷b

a/b

quotient of a÷b

||

or

&&

and

Print wheather a number is even or odd.

#include<conio.h>
#include<stdio.h>
void main()
{
clrscr();
int a;
scanf(“%d”,&a);
if (a%2==0)
{
printf(“%d is even”,a);
}
else
{
printf(“%d is odd”,a);
}
getch();
}

Print the greatest number among 3 given numbers.

#include<conio.h>
#include<stdio.h>
void main()
{
clrscr();
int a,b,c;
scanf(“%d %d %d”,&a,&b,&c);
if(a>b && a>c)
{
printf(“%d is the greatest”,a);
}
else if(b>a && b>c)
{
printf(“%d is the greatest”,b);
}
else if(c>a && c>b)
{
printf(“%d is the greatest”,c);
}
getch();
}

SCANF IS USED FOR USER INPUT

]]>
Pythagoras Theorem https://www.professorporua.squaryum.com/pythagoras-theorem/ Thu, 25 Jan 2024 11:15:37 +0000 https://www.professorporua.squaryum.com/?p=394

Geometry: Chapter 4

Pythagoras Theorem

If, ∠ABC = 90° (AB & BC is perpendicular to each other), then:

(AC)² = (AB)² + (BC)²

OR

c² = a² + b²

OR

(Hypotenuse)² = (Perpendicular)² + (Base)²

]]>
BODMAS https://www.professorporua.squaryum.com/bodmas/ Thu, 25 Jan 2024 11:03:43 +0000 https://www.professorporua.squaryum.com/?p=389

Mathematics: Chapter 2

BODMAS

Step 1:

Look for brackets and complete the calculations inside them, according bracket order:

FIRST    SECOND    THIRD

 

Step 2:

Look for any kind of roots (square roots, cube roots and others), indices (square of a number, cube of a number and others), exponents and powers.

 

Step 3:

Look for any kind of division and solve the calculations.

 

Step 4:

Look for any kind of multiplications and solve the calculations.

 

Step 5:

Look for any kind of additions and solve the calculations.

 

Step 6:

Look for any kind of subtractions and solve the calculations.

]]>
Introduction https://www.professorporua.squaryum.com/introduction/ Thu, 25 Jan 2024 10:48:27 +0000 https://www.professorporua.squaryum.com/?p=381

C Programming: Chapter 1

Introduction

Header Files

  • conio.h: CONsole Input Output (getch, clrscr)
  • stdio.h: STanDard Input Output (scanf, printf)
  • math.h: Mathematical functions (pow, sqrt, sin, cos, exp)
  • string.h: Character & string functions (char, strlen, String)

THERE ARE MANY OTHER HEADER FILES IN C
ALL ARE USABLE ACCORDING TO REQUIREMENTS

Print this line: “This is a test.”

#include<conio.h>
#include<stdio.h>
void main()
{
clrscr();
printf(“This is a test.”);
getch();
}

Print the addition result of 3 & 5.

#include<conio.h>
#include<stdio.h>
void main()
{
clrscr();
int a=3,b=5,c=0;
c=a+b;
printf(c);
getch();
}

PRINTF IS USED FOR SHOWING THE OUTPUT

]]>
Area Perimeter https://www.professorporua.squaryum.com/area-perimeter/ Wed, 24 Jan 2024 07:46:32 +0000 https://www.professorporua.squaryum.com/?p=368

Geometry: Chapter 3

Area & Perimeter

Circle

Rectangle

Square

Triangle

]]>
Karnaugh Map https://www.professorporua.squaryum.com/karnaugh-map-2/ Wed, 24 Jan 2024 07:38:10 +0000 https://www.professorporua.squaryum.com/?p=362

Boolean Algebra: Chapter 3b

Karnaugh Map

POS (Product Of Sum) & SOP (Sum Of Product)

POS Example:

SOP Example:

]]>