SOURCE CODE:
*Please follow the comments to better understand the code.
**Please look at the Screenshot below and use this code to copy-paste.
***The code in the below screenshot is neatly indented for better understanding.
#include <stdio.h>
int main()
{
int n,i,j,k;
printf("Enter N value: ");
scanf("%d",&n);
if(n>0)
{
//Triangle printed
for(i=0;i<n;i++)
{
for(j=0;j<=i;j++)
printf("A");
printf("\n");
}
}
else
{
//DIAMOND printed
n=-n;
//PRINT UPPER HALF
int space=n/2;
int count=1;
for(i=0;i<n/2;i++)
{
for(j=0;j<space;j++)
printf(" ");
for(k=0;k<count;k++)
printf("AA");
printf("\n");
count++;
space--;
}
//PRINT MIDDLE LINE
for(i=0;i<n/2+1;i++)
printf("AA");
printf("\n");
//PRINT LOWER HALF
space=1;
count=n/2;
for(i=0;i<n/2;i++)
{
for(j=0;j<space;j++)
printf(" ");
for(k=0;k<count;k++)
printf("AA");
printf("\n");
count--;
space++;
}
}
return 0;
}
============
SCREENSHOT
Exercise Write a program which asks the user to enter an integer n. It will print...
Write a program which asks the user to enter an integer. Use switch statement to write out the numeric word (such as ONE) if the user's input is 1; (see the sample run output for the usr input 2 or 3); otherwise, write OUT OF RANGE. Below are few sample runs: If the user enters a 1, the program will print: ONE TWO THREE Or, if the user enters a 2, the program will print: TWO THREE Or, if the...
Write a java program that asks the user to enter an integer. The program should then print all squares less than the number entered by the user. For example, if the user enters 120, the program should display 0, 1, 4, 9, 16, 25, 36, 49, 64, 81, and 100.
C++ Write a program that asks user for a positive integer side length. If they enter an illegal value, they must be prompted to enter a good one until they do. It then displays, using asterisks, a filled diamond of the given side length. For example, if the side length is 4, the program should display:
Exercise 1: Write a C++ program that asks the user to input an integer n followed by n other characters that will be stored in an array. We suppose here that the user will input only lowercase characters between ‘a’ and ‘z’. We also suppose that the user will input different characters. The program will then sort these characters according to an increasing order of their alphabetical order. In this exercise, feel free to use selection sort, insertion sort, or...
c++ please (1) Write a program that prompts the user to enter an integer value N which will rpresent the parameter to be sent to a function. Use the format below. Then write a function named CubicRoot The function will receive the parameter N and return'its cubic value. In the main program print the message: (30 Points) Enter an integer N: [. ..1 The cubic root of I.. ] is 2 update the code om part and write another function...
Write a Java program which asks the user to enter an integer x. This program prints the remainder of x when it is divided by 3. Example Pl ea s e e n t e r an i n t e g e r : 3 remainde r=0 Pl ea s e e n t e r an i n t e g e r : 17 remainde r=2
Write a program that prompts the user to enter an integer, n , and then n floating point numbers. As the numbers are read, the program will calculate the average of the negative numbers. In C language.
Write a C++ program that asks the user for 50 integer numbers and an integer n. The program will show then the pairs of numbers (a,b) where a=nb.
Write a short program in Java that asks the user for an integer. Then ask the user for a letter. Print out the letter followed by the integer.
Using loops, write a C# program that asks the user to enter repeatedly an integer number, it stops when the user enters -1, then the program should display how many numbers were entered, their the sum and their average