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

Practice Programs in C

Doing Programs gives you the great understanding about what you have learned. Doing Programs gives you the Confidence. So let's Start by doing some programming.

Uploaded by

ayan shaikh
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)
43 views3 pages

Practice Programs in C

Doing Programs gives you the great understanding about what you have learned. Doing Programs gives you the Confidence. So let's Start by doing some programming.

Uploaded by

ayan shaikh
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

Simple programs of C | Programmerdouts

programmerdouts.blogspot.com/2019/06/simple-programs-of-c.html

Simple Programs
Doing Programs gives you the great understanding about what you have learned.
Doing Programs gives you the Confidence.
So let's Start by doing some programming.

Q1: Declare a constant "pi" with value=3.14 by keyword "const" and print the value of
"pi" on the screen?

#include<stdio.h>
const float pi =3.14;

void main(){
printf("Constant Variable is %f",pi);
}

Output:
Constant Variable is 3.14
Exercise:
Q:Declare a same constant "pi" through Macros,display the constant
Hint: Use "#define pi 3.14",Bestofluck.

Q2:declare variable temp_c and assign 27.65C and convert it into Fahrenheit and
display Fahrenheit as well as temperature in Celcius.
Solution:

1/3
#include<stdio.h>

void main()
{
float temp_c,temp_f;
temp_c = 27.65; //temp_c variable
temp_f = temp_c+273.15; // temp_f variable

printf("Temperature in Celsius is %f C\n",temp_c);

printf("Temperature in Fahrenheit is %f F",temp_f);


}

Output:
Temperature in Celsius is 27.65 C
Temperature in Fahrenheit is 300.799988 F
Exercise:
Q:declare variable temp_f and assign 300.799988 and convert it into celsius and
display Celsius as well as temperature in Fahrenheit.
Hint: subtract 273.15 from temp_f variable,Bestofluck.

Q3: Declare variables radius assign 3.2 to it and Calculate Area of the circle and print
the result
Solution
#include<stdio.h>
#define pi 3.14
void main()
{
float radius = 3.2;
float Area;
Area = pi*(radius*radius); // radius*radius (method of taking square of variable)
printf("Area of the circle is %f",Area);

Output:
Area of the circle is 32.153603.
Exercise:
Declare variables radius assign 3.2 to it and Calculate
Some Maths equation in C
2/3
Maths Equations method to write in 'C'

ij+k (i*j)+k

i3 i*i*i

i 3+5 (i*i*i)+5

Algebraic Equation in 'C'

3/3

You might also like