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

PC IEEE Format

Uploaded by

Brunda A
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)
13 views3 pages

PC IEEE Format

Uploaded by

Brunda A
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

Programming in C

Batch 16
Vignan University
Vadlamudi, Guntur, Andhra Pradesh

A) You are organizing a children's art class and want to PROGRAM:


create a simple pattern for the kids to colour. Design a
triangle pattern where the kids can colour each row of the #include <stdio.h>
triangle. main()
Requirements {
1. The program should prompt the user to enter the height of int height, i, j;
the triangle. scanf("%d", &height);
2. Generate and display the triangle pattern. for (i = 1; i <= height; i++){
Eg: Enter the height of the triangle-5 for (j = 1; j <= i; j++) {
* printf('*');
** }
*** printf('\n');
**** }
***** }

ALGORITHM:
B) As a part of a school assignment on fractals, you need to
Step 1: Start generate a Pascal's triangle. The triangle should demonstrate
Step 2: Read h the mathematical properties of binomial coefficients.
Step 3: Initialize i =1, j=1 Requirements:
Step 4: Check i <=h The program should prompt the user to enter the number of
True, go to step 5, i++ rows for Pascal’s triangle.
False go to step 6 Generate and display Pascal's triangle pattern.
Step 5: Check j <= i Example: Number of rows for Pascal's triangle: 5
print * 1
j++, go to step 4 11
Step 6: Stop 121
1331
FLOWCHART: 14641

Develop a C program for the above

ALGORITHM:

Step 1: Start
Step 2: Read the number of rows rows from the user.
Step 3: Initialize i = 0.
Step 4: Check if i < rows:
- True: Go to Step 5
- False: Go to Step 9
Step 5: Initialize value = 1 Step 6: Initialize j = 0.
Step 7: Check if j <= i:
True: Print value, Update value using the formula:
value = value * (i - j) / (j + 1)
Increment j++ and go back to Step 7. -
False: Go to Step 8.
Step 8: Print a newline character \n after the current row is
printed.
Increment i++ and go back to Step 4.
Step 9: Stop.

XXX-X-XXXX-XXXX-X/XX/$XX.00 ©20XX IEEE


FLOWCHART: ALGORITHM:

Step 1: Start
Step 2: Read size (the dimensions of the square pattern).
Step 3: Initialize i = 0.
Step 4: Check if i < size:
- True: Go to Step 5
- False: Go to Step 11
Step 5: Initialize j = 0.
Step 6: Check if j < size:
- True: Go to Step 7
- False: Go to Step 10
Step 7: Calculate the layer value:
- Set layer = (i < j ? i : j) (smallest of i or j).
- Update layer = (layer < size - i ? layer : size - i
- 1) (smallest between current layer and size - i - 1).
- Update layer = (layer < size - j ? layer : size - j
- 1) (smallest between current layer and size - j - 1).
Step 8: Check if layer % 2 == 0:
- True: Print *
- False: Print a space " "
Step 9: Increment j++, go back to Step 6
Step 10: Print a newline character (\n) after completing one
PROGRAM:
row.
Increment i++ and go back to Step 4.
#include <stdio.h>
Step 11: Stop.
int main() {
int rows, i, j, value;
FLOWCHART:
scanf("%d", &rows);
for (i = 0; i < rows; i++) {
value = 1;
for (j = 0; j <= i; j++) {
printf("%d ", value);
value = value * (i - j) / (j + 1);
}
printf("\n");
}
return 0;
}

C) You are developing a console-based game that involves


navigating through concentric rectangles. Each level of the
game requires generating a more complex concentric
rectangle pattern.
Requirements:
The program should prompt the user to enter the size of the
concentric rectangles (odd number for height and width).
Generate and display the concentric rectangles pattern
Example: enter the size of the concentric rectangles (odd
number for height and width) - 7

*******
* *
* *** *
* * * *
* *** *
* *
*******
PROGRAM: Step 10: Print a newline character (\n) after completing one
row.
#include <stdio.h> Step 11: Increment i++ and go back to Step 4.
int main() { Step 12: Stop.
int size,i,j,layer;
scanf("%d",&size); FLOWCHART
for(i=0;i<size;i++){
for(j=0;j<size;j++){
layer=(i<j?i:j);
layer=(layer<size-i?layer:size-i-1);
layer=(layer<size-j?layer:size-j-1);
if(layer%2==0)
printf("*");
else
printf(" ");
}
printf("\n");
}
return 0;
}
D) You are asked with creating an interactive art installation
that involves a dynamic and complex pattern display the
pattern chosen is a wave matrix, which should be displayed
in a wave-like fashion based on user input

Requirements:
The program should prompt the user to enter the size of the
wave pattern generate and display the wave pattern

Example: For a size of 5, the output could be:


PROGRAM:
12345
10 9 8 7 6 #include <stdio.h>
11 12 13 14 15 int main() {
20 19 18 17 16 int size,i,j,num;
21 22 23 24 25 scanf("%d",&size);
for(i=0;i<size;i++){
if(i%2==0){
ALGORITHM: num=i*size+1;
for(j=0;j<size;j++){
Step 1: Start printf("%d ",num++);
Step 2: Read the size (the number of rows and columns in }
the grid). }else{
Step 3: Initialize i = 0. num=(i+1)*size;
Step 4: Check if i < size: for(j=0;j<size;j++){
- True: Go to Step 5 printf("%d ",num--);
- False: Go to Step 10 }
Step 5: Check if i % 2 == 0: }
- True: Set num = i * size + 1, then go to Step 6. printf("\n");
- False: Set num = (i + 1) * size, then go to Step
8. }
Step 6: Initialize j = 0. return 0;
Step 7: Check if j < size: }
True: Print the current value of num, then increment
num++, and increment j++.
Go back to Step 7.
False: Go to Step 9.
Step 8: Initialize j = 0.
Step 9: Check if j < size:
True: Print the current value of num, then decrement
num--, and increment j++.
Go back to Step 9.
False: Go to Step 10.

You might also like