write a program that reads in the size of the side of square and then pints a hollow square of that size out of asterisks and blanks?
You first learn how to program in C.
This algorithm reads the value of number of discs and prints the move that are to be done for playing towers of hanoi.Pre: n is a positive integer which carries the value of number of discs.Post: prints the moves that are to be done for transferring discs in ascending order in another peg1.initialize value of n(positive integer greater than 1)2.moves = pow(2,disk)-13.if(n=1)i) moves disk from "from" to "to"4. end if5. elsei)hanoi(n-1,from,aux,to)ii) moves disc from "from" to "to''iii) hanoi(n-i,from,aux,to)6.end else7. prints the movesend towers_of_hanoi
public class PrintValues { public static void main(String[] args) { for (int i = 1; i <=20; i++) { System.out.println("Value is: " + i); int sq = i * i; System.out.println(i + " Squared is: " + sq); } } }
#include<stdio.h> main() { int a,b,c,d; // The four integers to be asked printf("Give the first integer: "); //asks for the first integer scanf("%d",&a); // puts the user input in the address of the integer "a" printf("Give the second integer: "); //same explanations scanf("%d",&b); printf("Give the third integer: "); scanf("%d",&c); printf("Give the fourth integer: "); scanf("%d",&d); printf("1. The sum of the four integers is: %d",a+b+c+d); //prints the sum of the four integers given by the user, notice the "a+b+c+d" at the end) printf("2. The sum of the first two numbers minus the sum of the last: %d",a+b-c-d); //prints the second condition by putting the correct operations return 0; //ends the program } I never tested this program though, but i think it would work.
#include<iostream.h> void main(void) { int n; cout<<"Enter A Value For Triangle:"<<endl; cin>>n; cout<<endl; for(int i=n;i>=1;i--) { for(int j=1;j<=i;j++) cout<<" "; for(int k=2*n;k>=2*i;k--) cout<<"*"; cout<<endl; } cout<<endl; cout<<endl; for(int l=0;l<=n-4;l++) cout<<" "; cout<<"ENJOY"<<endl<<endl; }
A restaurant prints it out using a special program
ten
You first learn how to program in C.
This algorithm reads the value of number of discs and prints the move that are to be done for playing towers of hanoi.Pre: n is a positive integer which carries the value of number of discs.Post: prints the moves that are to be done for transferring discs in ascending order in another peg1.initialize value of n(positive integer greater than 1)2.moves = pow(2,disk)-13.if(n=1)i) moves disk from "from" to "to"4. end if5. elsei)hanoi(n-1,from,aux,to)ii) moves disc from "from" to "to''iii) hanoi(n-i,from,aux,to)6.end else7. prints the movesend towers_of_hanoi
public class PrintValues { public static void main(String[] args) { for (int i = 1; i <=20; i++) { System.out.println("Value is: " + i); int sq = i * i; System.out.println(i + " Squared is: " + sq); } } }
#include<stdio.h> main() { int a,b,c,d; // The four integers to be asked printf("Give the first integer: "); //asks for the first integer scanf("%d",&a); // puts the user input in the address of the integer "a" printf("Give the second integer: "); //same explanations scanf("%d",&b); printf("Give the third integer: "); scanf("%d",&c); printf("Give the fourth integer: "); scanf("%d",&d); printf("1. The sum of the four integers is: %d",a+b+c+d); //prints the sum of the four integers given by the user, notice the "a+b+c+d" at the end) printf("2. The sum of the first two numbers minus the sum of the last: %d",a+b-c-d); //prints the second condition by putting the correct operations return 0; //ends the program } I never tested this program though, but i think it would work.
Here's a simple C program that prompts the user for three decimal numbers, converts them to integers, and prints the trimmed integer values: c Copy code #include int main() { double num1, num2, num3; // Prompt the user for three decimal numbers printf("Enter three decimal numbers: "); scanf("%lf %lf %lf", &num1, &num2, &num3); // Convert and print the trimmed integer values int intNum1 = (int)num1; int intNum2 = (int)num2; int intNum3 = (int)num3; printf("Trimmed integer values: %d, %d, %d\n", intNum1, intNum2, intNum3); return 0; } In this program: We declare three variables num1, num2, and num3 to store the decimal numbers entered by the user. We use printf to prompt the user to enter three decimal numbers. We use scanf to read and store the user's input in the variables num1, num2, and num3. We then convert these decimal numbers to integers by casting them using (int) and store them in intNum1, intNum2, and intNum3. Finally, we use printf again to print the trimmed integer values. Compile and run the program, and it will prompt you for three decimal numbers and print their trimmed integer values as requested.
#include<iostream.h> void main(void) { int n; cout<<"Enter A Value For Triangle:"<<endl; cin>>n; cout<<endl; for(int i=n;i>=1;i--) { for(int j=1;j<=i;j++) cout<<" "; for(int k=2*n;k>=2*i;k--) cout<<"*"; cout<<endl; } cout<<endl; cout<<endl; for(int l=0;l<=n-4;l++) cout<<" "; cout<<"ENJOY"<<endl<<endl; }
/* my second program in C++ with more comments */ #include <iostream> using namespace std; int main () { cout << "Hello World! "; // prints Hello World! cout << "I'm a C++ program"; // prints I'm a C++ program return 0; }
Prices rise when the government prints too much money.
reymond rillera reymond rillera
Your program is wrong.