Help with a C code!
Multidimensional Array problem:
a)
prompt the user for the number of rows they want. Then, print an
array of stars.
For example, if user prompts "5", the output should look like:
*
* *
* * *
* * * *
* * * * *
b)
Do the same, but inverse the table.
If user types 5 for their prompt, output will look like:
* * * * *
* * * *
* * *
* *
*
Please help me write this code! I'm having troubles with multidimensional array coding for C
Thanks!
THE PROGRAM IS WRITTEN IN C.
ANS a.
SOURCE CODE:
#include<stdio.h>
int main()
{
int n,i=0,j;
scanf("%d",&n);
for(i=1;i<=n;i++) /*this will run eqauls number of
row*/
{
for(j=1;j<=i;j++) /*this for
loop will run only till it prints '* ' equal to row number */
{
printf("*
");
}
printf("\n");
}
return 0;
}
OUTPUT:
5
*
* *
* * *
* * * *
* * * * *
-------------------------------
ANS B.
SOURCE CODE:
#include<stdio.h>
int main()
{
int n,i=0,j;
scanf("%d",&n);
for(i=1;i<=n;i++) /*this will run eqauls number of
row*/
{
for(j=i;j<=n;j++) /*this for
loop will run print * for the first equal to number of number and
then drecreases by 1 each step */
{
printf("*
");
}
printf("\n");
}
return 0;
}
OUTPUT:
5
* * * * *
* * * *
* * *
* *
*
--------------------------------
Help with a C code! Multidimensional Array problem: a) prompt the user for the number of...
Create a C# program that will first prompt the instructors to enter the number of students they currently have in their classes. Use this value for the size of the row dimension of your multidimensional array. Next, prompt the instructors to type in the number of scores they would like to enter. This variable will be used to designate the column size dimension of your multidimensional array. Then, use a loop to prompt the user to enter the number of...
1. Prompt the user for one of the arithmetic operators ('op'): +, -, *,/, or ** 2. Prompt the user for two input integers ('a' and'b') 3. The input numbers can be positive or negative 4. Perform the arithmetic operation using the two input numbers 5. The first entered number ('a') is the left side, the second ('b') the right side of the operation For exponentiation, the first number is the base, the second the exponent Print (display) the following...
Problem 1: Dynamic Grocery Array Using Java to write a program that prompts the user to enter an item’s name for each position in the array. The program then prints uses a loop to output the array. Example 1: Banana 2: Orange 3: Milk 4: Carrot 5: Chips Banana, Orange, Milk, Carrot, Chips Problem 2: Print Characters in String Array Declare a string array of size 5. Prompt the user enters five strings that are stored in the array....
C++ Code Writing Prompt: Countdown: Write a countdown program that prompts the user for a max value (i.e. 30). Print out a countdown from that number down to zero, then print “blast off!”
This program will make Maze game. Please Help in c++ Prompt the user for a file that contains the maze. Read it into a two-dimensional array Remember you can use inputStream.get(c) to read the next character from the inputStream. This will read whitespace and non-whitespace characters Don’t forget to read the newline character at the end of each line Print the maze to the screen from your array You should include a ‘*’ in your maze to indicate where the...
C Programming For this task, you will have to write a program that will prompt the user for a number N. Then, you will have to prompt the user for N numbers, and print then print the sum of the numbers. For this task, you have to create and use a function with the following signature: int sum(int* arr, int n); Your code should look something like this (you can start with this as a template: int sum(int* arr, int...
Write a code using loop and flag function in python jupitior notebook: Ask the user for the number of items they bought. Also ask the price of each item they bought and quantity purchased. Display the total amount they owe. Ask the user for a number n. Calculate 1+2+3+….+n. Ask the user for a number n. Calculate 1*2*3*…*n. Ask the user for number of rows (r) and columns (c). Print * for r rows and c columns. Ask the user...
Code in C++ Instructions Write a program which... Prompt the user to enter the number of values that they would like to insert into a binary search tree. Prompt the user to insert, one-at-a-time, a value into the binary search tree. Print the preorder, postorder, and inorder traversal on the tree. Binary Search Tree The methods preorder, postorder, inorder, preorderR, postorderR, and inorderR will all contains the necessary screen output statements to verify that the traversal is happening correctly (see...
In C only Please! This lab is to write a program that will sort an array of structs. Use the functions.h header file with your program. Create a source file named functions.c with the following: A sorting function named sortArray. It takes an array of MyStruct's and the length of that array. It returns nothing. You can use any of the sorting algorithms, you would like though it is recommended that you use bubble sort, insertion sort, or selection sort...
In C code prompt and read from the user an integer number, 'N', of double precision floating point numbers to allocate for the purpose of the current test run. Dynamically allocate an array of N double precision floating point numbers; i.e. the array will require "N*sizeof(double)" bytes of RAM for storage, call this M.