The do while loop is useful for the special loops that they must circulate at least one time.
#include <iostream>
using namespace std;
int main()
{
int num,digit;
cout<<"Enter a #\n";
cin>>num;
cout<<"Invers is : ";
do
{
digit=num/10;
cout<<digit;
num/=10;
} while(num != 0);
return 0;
}
Wiki User
∙ 14y agoWiki User
∙ 13y ago//do while example
#include<stdio.h>
int main(void)
{
const int SECRET_CODE = 15;
int code;
do{
printf("Type the secret code number to enter.\n");
scanf("%d", &code);
}while(code!=SECRET_CODE);
printf("Well done , you can now enter\n");
return 0;
}
#include <stdio.h>
main()
{
int i = 10;
do
{
printf("Hello %d\n", i );
i = i -1;
}while ( i > 0 );
}
/*break in do while*/
#include <stdio.h>
main()
{
int i = 10;
do
{
printf("Hello %d\n", i );
i = i -1;
if( i == 6 )
{ break;
}
}while ( i > 0 );
}
Wiki User
∙ 10y ago#include<iostream>
int main()
{
// Count from 1 to 10 using do-while loop.
int i=0;
do
{
std::cout<<++i<<std::endl;
}while i<10);
// Note: i is 10 at this point...
}
Wiki User
∙ 12y agoUnlike the while() loop, a do..while() loop always executes at least once. Iteration is dependant on the conditional expression which is evaluated at the end of the loop, whereas a while() loop's conditional expression is evaluated before entering the loop, and may never execute. for() loops are also evaluated before entering the loop, but the conditional expression is optional.
Wiki User
∙ 14y agoint main (int argc, char **argv)
{
int i;
i= -1;
while (++i < argc) printf ("%d. '%s'\n", i, argv[i]);
}
Wiki User
∙ 13y agousable
do statement while (expression);
No, why did you think so?
for( ; ; ) { statement_block; } while( conditional_expression ) { statement_block; } do { statement_block; }while( conditional_expression )
int i = 0; while(str[i] != NULL){ i++; }
An attribute is a class member variable while a behaviour is a class member method.
C++ allows multiple inheritance while Java does not. In my opinion, multiple inheritance is not useful because it can get very confusing very quick. For polymorphism, C++ does early binding by default, while Java does late binding by default. Late binding is more useful than early binding.
kk
if while switch
Iterative loops in C/C++ are represented by for(), while() and do...while() code blocks. Recursive loops are represented by functions calling themselves.
There is none. While you can access databases from C++, the two concepts are fundamentally different.
With slight variations, everything in C is included in C++. However, while C is a procedural language, C++ is object-oriented, so C++ essentially shares nothing with C. C++ is, quite literally, the successor to C.
how do we use loops in c plus plus programing and what are basic differences between do,for and while loop
No, why did you think so?
for( ; ; ) { statement_block; } while( conditional_expression ) { statement_block; } do { statement_block; }while( conditional_expression )
It was developed by Bjarne Stroustrup while he was working at AT&T Bell Labs.
Add the missing parts.
b+b+b+c+c+c+c =3b+4c
c + c + 2c + c + c = 6c