Question

In: Computer Science

C++ please. Define a problem with user input, user output, Pointer, with const and sizeof operator.

C++ please. Define a problem with user input, user output, Pointer, with const and sizeof operator.

Solutions

Expert Solution

If you have any queries please comment in the comments section I will surely help you out and if you found this solution to be helpful kindly upvote.

Solution :

#include <iostream>
using namespace std;
// main function
int main()
{
// declare an integer
int a;
// input the integer
cin>>a;
// create constant size for the array
const int size = a;
// declare a dynamic array using pointer
int *arr;
// initialize the array using malloc and sizeof
arr = (int*)malloc(size * sizeof(int));
// input array elements
for(int i=0;i<size;i++)
{
cin>>arr[i];
}
// print array elements
for(int i=0;i<size;i++)
{
cout<<arr[i]<<" ";
}
return 0;
}


Related Solutions

Define a problem with user input, user output, -> operator and destructors. C ++ please
Define a problem with user input, user output, -> operator and destructors. C ++ please
Define a problem with user input, user output, Switch and some mathematical computation. Write the pseudocode,...
Define a problem with user input, user output, Switch and some mathematical computation. Write the pseudocode, code and display output. Include source code and output. If no output explain the reason why and what you are going to do make sure it does not happen again aka learning from your mistakes. Problem: Pseudocode: Code: Output:
Define a problem with user input, user output, While Statement and some mathematical computation. Write the...
Define a problem with user input, user output, While Statement and some mathematical computation. Write the pseudocode, code and display output.
Define a java problem with user input, user output, Do While Statement and some mathematical computation....
Define a java problem with user input, user output, Do While Statement and some mathematical computation. Write the pseudocode, code and display output.
Create a C++ program that will prompt the user to input an integer number and output...
Create a C++ program that will prompt the user to input an integer number and output the corresponding number to its numerical words. (From 0-1000000 only) **Please only use #include <iostream>, switch and if-else statements only and do not use string storing for the conversion in words. Thank you.** **Our class is still discussing on the basics of programming. Please focus only on the basics. Thank you.** Example outputs: Enter a number: 68954 Sixty Eight Thousand Nine Hundred Fifty Four...
Write a program in C, that uses standard input and output to ask the user to...
Write a program in C, that uses standard input and output to ask the user to enter a sentence of up to 50 characters, the ask the user for a number between 1 & 10. Count the number of characters in the sentence and multiple the number of characters by the input number and print out the answer. Code so far: char sentence[50]; int count = 0; int c; printf("\nEnter a sentence: "); fgets(sentence, 50, stdin); sscanf(sentence, %s;    for(c=0;...
Ask the user to input a series of numbers, write a C# program to output the...
Ask the user to input a series of numbers, write a C# program to output the sum, max, and min. Be sure to do error checking if the user input is not a number.
Create a C++ program that will prompt the user to input an integer number and output...
Create a C++ program that will prompt the user to input an integer number and output the corresponding number to its numerical words. (From 0-1000000 only) **Please only use #include <iostream> and switch and if-else statements only. Thank you. Ex. Enter a number: 68954 Sixty Eight Thousand Nine Hundred Fifty Four Enter a number: 100000 One Hundred Thousand Enter a number: -2 Number should be from 0-1000000 only
How is a const pointer similar and different from a reference variable? And please give a...
How is a const pointer similar and different from a reference variable? And please give a good example. Please help! Thank you!
Define a problem utilizing Stacks. Write the design, code and display output. please in c++ oop?
Define a problem utilizing Stacks. Write the design, code and display output. please in c++ oop?
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT