Example 5.13: BASIC program that finds the sum of numbers from 1 to 50, prints the
sum and stops at 50th pass.
CLS
Sum = 0
FOR K = 1 TO 50
Sum = Sum + K
NEXT K
PRINT “SUM=”, Sum
END
Example 5.13: C-program that finds the sum of any set of numbers (i.e from 1 to 50),
prints the sum and stops at 50th pass.
#include <stdio.h>
#include <math.h>
int main()
{
int increase, number, sum = 0;
printf("Enter an integer number \n");
scanf ("%d", &number);
for (increase = 1; increase <= number; increase++)
{
sum = sum + increase;
}
printf ("Sum of first %d natural numbers = %d\n", number, sum);
}
Example 5.14: BASIC program that finds the square root of the sum of numbers from
59 to 2000.
CLS
Sum = 0
FOR K = 59 TO 2000
Sum = Sum + K
NEXT K
Squareroot = SQR (Sum)
PRINT “SQUARE ROOT = “, Squareroot
END
Example 5.14: C- program that finds the square root of the sum of numbers from 59 to
2000.
#include <stdio.h>
#include <math.h>
int main()
{
int increase, number, Squareroot, sum = 0;
printf("Enter an integer number");
scanf ("%d", &number);
for (increase = 59; increase <= number; increase++)
{
sum = sum + increase;
Squareroot = (sqrt(sum));
}
printf ("Squareroot of the numbers = %d\n", Squareroot);
}
Example 6.21: BASIC program that reads and calculates the volume of a cone using
READ and DATA statements.
H
R
L
Cone
Fig. 6.6: A cone
CLS
READ radius, height
Volume = (1 / 3) * (3.142]) * ((radius) ^ 2) * (height)
PRINT "PROGRAM THAT CALCULATES THE VOLUME OF A
CONE USING READ AND DATA STATEMENT"
PRINT " VOLUME =", Volume
DATA 23,19,128
END
Example 6.21: C-program that reads and calculates the volume of a cone using READ
and DATA statements.
#include <stdio.h>
#include <math.h>
int main()
{
float radius, height;
float surface_area, volume;
printf("Enter value of radius and height of a cone ");
scanf("%f%f", &radius, &height);
volume = (1.0/3) * (3.142) * (pow(radius, 2))* height;
printf(" Volume = %.2f", volume);
return 0;
}
© Copyright 2026 Paperzz