Documentating
Pre processor
Globa; declarations
Void main (void)
{
Local declarations statements }
b) EVENLY DIVISIBLE BY 4
#include<stdio.h>
Int main ()
{
Int number;
Printf(enter a number\n);
Scanf(%d,&number); If(number %4==0)
{
Printf(evenly divisible by 4);
}
Else
{
Printf(not divisible by 4);
Return 0; }
C) 6 RELATIONAL OPERATOR
== check if the value of 2 operator are equal or not,
if yes then condition is true
!= not equal to
Greater than
< less than
>= greater than or equal to
<less than or equal to
d) h=(0.5)
#include<stdio.h>
#include<math.h>
Int main()
{
Float h,g,t,u,x;
Printf(please input, initial velocity, initial height,
acceleration due to gravity\n);
Scanf(%f %f %f %f, &t, &u, &x, &g)
Printf(height reached by the projectile = %f\n,h);
Return 0; }
2)i) 3 TYPE SELECTION STATEMENTS
a)if (single selection)
- if condition is true perform action,, if condition is
false, action is skipped, program continues
If(condition)
{
Statements;
}
b) if.. else(double selection)
-if condition is true perform action,, else (if
condition is false) perform a different action (this
will skip if condition is true)
If (expression)
Action statements -1
Else
Action statements -2
c) switch(multiple selection)
-allows selection among many actions depending on
the integral value of variable or expression
Switch(vor)
case constant 1; statement;
Break;
case constant 2; statement;
Break;
Default: statement;
Break;
}
ii) exmpl multiple
what is the output:
int x,y;
x=3; y=5; if (x<2)
printf(%d\n,x);
else
printf(%d\n,y);
b)RADIUS OF CIRCLE
#include<stdio.h>
#include<math.h>
Int main ()
{
float pi=3.142;
int choice;
float radius,circum,area,square;
printf(please input radius\n);
scanf(%f,&radius);
printf(1.circumference of circle\n);
printf(2.area of the circle\n);
printf(3.largest square in\n);
scanf(%d,&choice);
switch (choice)
{
Case 1: circum=2*pi*radius;
Printf(circumference is =%f\n, circum);
Break;
Case 2 : area = pi*radius*radius;
Printf(area of circle is %f\n,area);
Case 3 : square = 2*radius*radius;
Printf(largest square is = %f\n,square);
Break;
Default : printf(invalid selection\n);
}
Return 0;
}
3) b) TENSILE STRENGHT
#include<stdio.h>
Int main ()
{
Int tensile;