Assignment C++ Programming

14
ASSIGNMENT C++ QUESTIONS 1. Who is Written C++ C++ programming is one of the most popular and widely used object- oriented programming language which was developed by Bjarne Stroustrup in 1979. C++ is derived from C programming. So, almost all code that run on C runs correctly on C++. If you have good understanding of basic features of C programming, you will have a head start learning C++. 2. State statements below and give an example application in C++ a. Go to // goto_statement.cpp #include <stdio.h> int main() { int i, j; for ( i = 0; i < 10; i++ ) { printf_s( "Outer loop executing. i = %d\n", i ); for ( j = 0; j < 2; j++ ) { printf_s( " Inner loop executing. j = %d\n", j ); if ( i == 3 ) goto stop; } } // This message does not print: printf_s( "Loop exited. i = %d\n", i ); stop: printf_s( "Jumped to stop. i = %d\n", i ); b. While

description

Assignment C++ Programming

Transcript of Assignment C++ Programming

Assignment c++questions1. Who is Written C++C++ programming is one of the most popular and widely used object-oriented programming language which was developed by Bjarne Stroustrup in 1979. C++ is derived from C programming. So, almost all code that run on C runs correctly on C++. If you have good understanding of basic features of C programming, you will have a head start learning C++.2. State statements below and give an example application in C++a. Go to// goto_statement.cpp#include int main(){ int i, j;

for ( i = 0; i < 10; i++ ) { printf_s( "Outer loop executing. i = %d\n", i ); for ( j = 0; j < 2; j++ ) { printf_s( " Inner loop executing. j = %d\n", j ); if ( i == 3 ) goto stop; } }

// This message does not print: printf_s( "Loop exited. i = %d\n", i ); stop: printf_s( "Jumped to stop. i = %d\n", i );

b. While

How while loop works in C++ Programming?Thewhileloop checks whether the test expression is true or not. If it is true, code/s inside the body of while loop is executed,that is, code/s inside the braces { } are executed. Then again the test expression is checked whether test expression is true or not. This process continues until the test expression becomes false.Example 1: C++ while LoopC++ program to find factorial of a positive integer entered by user. (Factorial of n = 1*2*3...*n)#include using namespace std;

int main() { int number, i = 1, factorial = 1; cout> number; while ( i number;

if ( number > 0) { // Checking whether an integer is positive or not. cout