0% found this document useful (0 votes)
14 views3 pages

CAT 1 Submission

The document describes three main types of constants: integer constants, floating constants, and character constants. It defines a literal as a fixed value in code and outlines two rules for naming variables in C programming. Additionally, it provides a sample program that calculates the area and circumference of a circle based on user input for the radius, using a defined constant for PI.

Uploaded by

ndegwageorge345
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views3 pages

CAT 1 Submission

The document describes three main types of constants: integer constants, floating constants, and character constants. It defines a literal as a fixed value in code and outlines two rules for naming variables in C programming. Additionally, it provides a sample program that calculates the area and circumference of a circle based on user input for the radius, using a defined constant for PI.

Uploaded by

ndegwageorge345
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

A.

Briefly describe the three main types of constants

Integer Constants-numbers without any fraction or decimal points

Floating constants- represent numbers with decimal points or written in scientific notation

Character constants-single characters enclosed in single quotes

B. Rewrite the following sample while using a while loop

C. Define the term literal

A literal is a fixed value directly written in the code representing constant data

D. State two rules followed in the naming of variables in C programming

Begin with a letter or underscore, a variable cannot start with a digit

No special spaces or characters, variable names can only include digits, letters and underscore
E. Write a program that prompts the user to enter the radius of a circle.The program should then
compute both area and circumference of a circle. PI should be declared as a constant

#include <stdio.h>

// Define PI as a constant
#define PI 3.14159

int main() {
float radius, area, circumference;

// Prompt the user to enter the radius of the circle


printf("Enter the radius of the circle: ");
scanf("%f", &radius);

// Calculate the area and circumference


area = PI * (radius * radius);
circumference = 2 * PI * radius;

// Display the results


printf("The area of the circle is: %.2f\n", area);
printf("The circumference of the circle is: %.2f\n", circumference);

return 0;
F.

You might also like