


Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Computer programming Assignment
Typology: Exercises
1 / 4
This page cannot be seen from the preview
Don't miss anything!



1. Write a program that generates the following output:
This is my first program in Visual C++
“This is my first program in Visual C++”
This \ is \ my \ first \ program \ in \ Visual \ C++ \
2. What will be the output when the following line of code is executed:
cout << “This is how\t\bEscape Sequences\b work\r*”;
3. Write a program that accepts an integer from the user. Compute the square and cube of that number. The output should look something like this:
Enter an integer: 10
10‟s square is 100
10‟s cube is 1000
4. Write a program that accepts 5 integers from the user and computes their sum and average.
Enter the first number: 1
Enter the second number: 10
Enter the third number: -
Enter the fourth number: 20
Enter the fifth number: 4
The Sum of these numbers is 25
The Average of these numbers is 5
5. What is wrong with the following programs:
#include <iostream.h>
int main (int argc, char* argv[])
{
cout << “This is my first program”;
}
#include <iostream.h>
int main (int argc, char*argv[])
{
cout >> “Hello World!”;
return 0;
}
_______ main(__________)
{
____ << I have saved my file at ____MyFile << endl;
_________ ;
}
The program is supposed to display this message “I have saved my file at D:\MyFile\”
8. Write a program that asks the user to enter „n‟ numbers and displays their sum and average at the end. („n‟ is any real number greater than or equal to 2). Use a for- loop to solve this question. For-loops have been explained in the „Pre-lab‟ posted on **this website.