0% found this document useful (0 votes)
288 views

C. Flowchart. (Prime Numbers) : Start

The document provides the program plan, algorithm, flowchart, and pseudocode to write a C program that reads in 10 integers between 0-100, counts how many are greater than or equal to 50, and prints the count and list of numbers meeting that criteria. It initializes arrays and variables, uses a for loop to input the numbers and increment the count if greater than or equal to 50, and finally prints the output.

Uploaded by

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

C. Flowchart. (Prime Numbers) : Start

The document provides the program plan, algorithm, flowchart, and pseudocode to write a C program that reads in 10 integers between 0-100, counts how many are greater than or equal to 50, and prints the count and list of numbers meeting that criteria. It initializes arrays and variables, uses a for loop to input the numbers and increment the count if greater than or equal to 50, and finally prints the output.

Uploaded by

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

Start

C. Flowchart. (Prime numbers)

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.

Step 1: Print Prime Numbers

Step 2: for(int i=2;i<=100;i++) { int counter = 0;

for(int j=2;j<=sqrt(i);++j){

if (i%j==0)

counter=1; }

if(counter==0)

cout <<i<< " "

D. Pseudocode.

Start program

Print Prime Numbers

for(int i=2;i<=100;i++) int counter =0;

for(int j=2;j<=sqrt(i);++j)

if (i%j==0) counter=1;

if(counter==0)

Print i “ ”
E. Iteration table.

Iteration Variable i<=100 Action

i =2 Not checked 2 is printed and i is


increased to 3
1st i =3 True 3 is printed and i is
increased to 5
2nd i =5 True 5 is printed and i is
increased to 7
3rd i =7 True 7 is printed and i is
increased to 11
4th i =11 True 11is printed and i is
increased to 13
5th i =13 True 13 is printed and i
is increased to 17
6th i =17 True 17 is printed and i
is increased to
19….
26th i = 101 False The loop is terminated
C. Flowchart. (no.5)

Start

Int num, temp,


counter = 0;

Get num

Temp =
num

while(temp
!= 0)

counter++; temp /= 10;

Print num and counter

End
A. Program plan

Counting Numbers

Enter the number: 404

Output:

Total digits in 404 is 3.

B. Algorithm.

Step 1: Initialize num, temp, counter = 0;

Step 2: Print Enter the number:

Step 3: Get num

Step 4: temp = num

Step 5: while (temp != 0){

counter++; temp /= 10;

Step 6: Print Total digits (num) is (counter)

Step 7: End.

D. Pseudocode.

Start Program

int num,temp, counter=0;

Print Counting Numbers

Print Enter the number cin: num

temp = num

while (temp != 0){ counter++; temp /= 10; }

Print Total digits of num is counter.

E. Iteration Table.

Iteration Variable temp != 0 Action


temp = num TRUE Num and counter is
printed
7. Write a program that reads 10 integers in the range 0 – 100 from the
keyboard, and counts how many of them are greater than 50, and finally
displays the count and the list of the numbers.

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

Print numbers greater


than or equal to 50

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

Input the coordinates (x, y): 2, 3

The coordinates point (2, 3) lies in First Quadrant

B. Algorithm.

Step 1: Initialize int x, y

Step 2: Print Coordinates

Step 3: Input the coordinate (x, y)

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

If x > 0 and y > 0 print First Quadrant x, y.

Else If x < 0 and y > 0 print Second Quadrant x, y.

Else If x < 0 and y < 0 print Third Quadrant x, y.

Else If x > 0 and y < 0 print Fourth Quadrant x, y.

You might also like