C. Flowchart. (Prime Numbers) : Start
C. Flowchart. (Prime Numbers) : Start
i<=100 increment
int counter =
0;
j<=sqrt(i increment
)
if (i
%j==0)
counter=1;
if(counte
r==0) Print <<i<< " "
End
CODES:
Progr
am plan
Prime Numbers
Output:
2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97
B. Algorithm.
for(int j=2;j<=sqrt(i);++j){
if (i%j==0)
counter=1; }
if(counter==0)
D. Pseudocode.
Start program
for(int j=2;j<=sqrt(i);++j)
if (i%j==0) counter=1;
if(counter==0)
Print i “ ”
E. Iteration table.
Start
Get num
Temp =
num
while(temp
!= 0)
End
A. Program plan
Counting Numbers
Output:
B. Algorithm.
Step 7: End.
D. Pseudocode.
Start Program
temp = num
E. Iteration Table.
A. Program Plan.
Enter the ten numbers:
1 17 8 45 30 65 79 90 89 88
Output:
The number of integers greater or equal to 50 is: 5
B. Algorithm.
Step 1: Initialize int a[100],i,b=0,N=10;
Step 2: for(i=0;i<N;i++)
Step 3: Get a[i]
Step 4: if (a[i]>=50) b++;
Step 5: Print numbers greater than or equal to 50.
D. Pseudocode.
Start program
Initialize int a[100],i,b=0,N=10;
for(i=0;i<N;i++)
get a[i]
if (a[i]>=50) b inrement
print The number of integers greater or equal to 50 is: b
C. Flowchart.
START
int
a[100],i,b=0,N=
10;
i<N;
Get a[i]
If
a[i]>=50
Increment
End
8. Write a C program to accept a coordinate point in an XY coordinate system and
determine in which quadrant the coordinate point lies.
A. Program Plan.
Int x, y;
Coordinates
B. Algorithm.
Step 4: if (x>0 && y>0) print “The coordinate point (%d,%d) lies in First Quadrant " x and y.
else if (x<0 && y>0) print “The coordinate point (%d,%d) lies in second Quadrant ",x and y.
else if (x<0 && y<0) print “The coordinate point (%d,%d) lies in Third Quadrant ",x and y.
else if (x>0 && y<0) print “The coordinate point (%d,%d) lies in Forth Quadrant ",x and y.
C. Flowchart.
Start
int x,y;
Get x, y
if (x>0 &&
y>0)
else if (x<0
Print First Quadrant && y>0)
x, y
Print Second
Quadrant x, y
else if
(x<0 &&
y<0)
else if
(x>0 &&
y<0)
Print Third
Quadrant x, y
Print Fourth
Quadrant x, y
End
D. Pseudocode.
Start program
int x, y;
Print Coordinates
Input x, y