Function Main
Declare Integer n
Declare Integer reverse
Assign reverse = 0
Declare Integer remainder
Output "Enter an integer: "
Input n
While (n!=0)
Assign remainder = n % 10
Assign reverse = reverse * 10 + remainder
Assign n = n / 10
End
Output " Reversed number = " &reverse
End
Function Main
Declare Real celsius
Declare Real fahrenheit
Output "Enter temperature in Celsius: "
Input celsius
Assign fahrenheit = (celsius * 9 / 5) + 32
Output "Fahernheit is : " &fahrenheit
End
Function Main
Declare Real radius
Declare Real area
Declare Real Circumference
Output "Enter the radius of Circle : "
Input radius
Assign area = 3.1416 * radius * radius
Assign Circumference = 2 * 3.1416 * radius
Output "Area of Circle : " &area
Output "Circumference of circle: " &Circumference
End
Function Main
Declare Integer i
Declare Integer j
Declare Integer n
Output "Enter a number: "
Input n
For i = 1 to n
For j = 1 to i
Output "* "
End
Output ""
End
End
#include <stdio.h>
int main()
{
int i;
int j;
int n;
printf("Enter a number:");
scanf("%d", &n);
for (i = 1; i <= n; i++)
{
for (j = 1; j <= i; j++)
{
printf("* "); // output * pattern or number or symbol
}
printf("\n");
}
return 0;
}
// This code show us left, right, inverted pattern, if we can organized it.
#include <stdio.h>
int main()
{
int i, j, k, rows;
printf("Enter the no. of rows: ");
scanf("%d", &rows);
for (i = 1; i <= rows; i++)
{
// for (j = i; j <= rows; j++)
// printf(" ");
for (k = 1; k <= i; k++)
printf(" %d", k);
printf("\n");
}
return 0;
}
#include <stdio.h>
int main()
{
int i, j, rows, k = 0;
printf (" Enter a number of rows:");
scanf ("%d", &rows);
for ( i =1; i <= rows; i++)
{
for ( j = 1; j <= rows - i; j++)
{
printf (" ");
}
// use for loop where k is less than equal to (2 * i -1)
for ( k = 1; k <= ( 2 * i - 1); k++)
{
printf ("%d ", k); }
printf ("\n");
}
}
Function Main
Declare Real base
Declare Real height
Declare Real Area
Declare Real Perimeter
Output "Enter value of base:"
Input base
Output "Enter height: "
Input height
Assign Area = (base * height)
Output "The Area is: " &Area
Assign Perimeter = (base + height) * 2
Output "The Perimeter is: " &Perimeter
End
Function Main
Declare Real base
Declare Real height
Declare Real Area
Output "Enter base: "
Input base
Output "Enter height:"
Input height
Output "The area of the triangle is "
Output (base * height) / 2
End
Function Main
Declare Integer a
Declare Integer b
Output "Enter first number: "
Input a
Output "Enter second number: "
Input b
Assign a = a + b
Assign b = a - b
Assign a = a - b
Output "Now first number is: " & a
Output "Now second number is: " & b
End
#include <stdio.h>
int main() {
int a;
int b;
printf("Enter first number:");
scanf("%d", &a);
printf("Enter second number:");
scanf("%d", &b);
a = a + b;
b = a - b;
a = a - b;
printf("Now first number is second number:%d\n ", a);
printf("Now second number is first number:%d ", b);
return 0;
}
Function Main
Declare Integer a
Declare Integer b
Declare Integer temp
Output "Enter first number: "
Input a
Output "Enter second number: "
Input b
Assign temp = a
Assign a = b
Assign b = temp
Output "Now first number is: " & a
Output "Now second number is: " & b
End
#include <stdio.h>
int main() {
int a;
int b;
int temp;
printf("Enter first number:");
scanf("%d", &a);
printf("Enter second number:");
scanf("%d", &b);
temp = a;
a = b;
b = temp;
printf("Now first number is second number:%d\n", a);
printf("Now second number is first number:%d ", b);
return 0;
}
Function Main
Declare Integer a
Declare Integer b
Declare Integer sum
Output "Enter first number: "
Input a
Output "Enter second number: "
Input b
Assign sum = a + b
Output "The sum is: " sum
End
#include <stdio.h>
int main() {
int a;
int b;
int sum;
printf("Enter first number: ");
scanf("%d",&a);
printf("Enter second number: ");
scanf("%d",&b);
sum = a + b;
printf("The sum is: %d", sum);
return 0;
}