unsigned count = 0;unsigned num=1; do { std::cout << num << std::endl; num +=2; } while (++count<50);
It is too easy................ //Program to print numbers vertically #include<stdio.h> #include<conio.h> void main() { int last_no; int i; clrscr(); i=0; printf("Enter your last num.I will print 0 to that number"); scanf("%d",&last_no); printf("\n"); while(i>last_no) { printf("%d\n",i); i++; } getch(); } //poo.papule
CLS PRINT "PROGRAM: Print squares of all even numbers from 1 to 20" PRINT PRINT "number", "squared" PRINT FOR number% = 1 TO 20 IF number% MOD 2 = 0 THEN PRINT number%, number% * number% END IF NEXT END
#include<iostream> unsigned print_naturals (unsigned max) { unsigned num = 0; while (num<max) std::cout << ++num << ' '; std::cout << std::endl; } int main() { // print first 10 natural numbers: print_naturals (10); // print first 100 natural numbers: print_naturals (100); }
#include<stdio.h> main() { int a,i=1; printf("Enter max no"); scanf("%d",&a); do { printf("%d",i); i=i+2; }while(i<=a); }
//program to find the factorial value f any number using while loop #include<stdio.h> void main() { int i,n,fact=1; printf("Enter the number\n"); scanf("%d",&n); i=n; while (i>=1) { fact=fact*i; i--; } printf("The factorial value=%d",fact); } the above is a program for calculating tha factorial value of any number which is entered by the user
int i=0; while (i++<n) { /*...*/ }
"While it is possible to use this program to print a book, it is highly recommended to print it with an actual publisher. You will get a much better deal and your book will look a lot more professional."
Write a c program to print the 100 to 1 nos
x as int = 0 while x < 50 x = x + 1 print x endwhile
how do we use loops in c plus plus programing and what are basic differences between do,for and while loop
unsigned count = 0;unsigned num=1; do { std::cout << num << std::endl; num +=2; } while (++count<50);
It is too easy................ //Program to print numbers vertically #include<stdio.h> #include<conio.h> void main() { int last_no; int i; clrscr(); i=0; printf("Enter your last num.I will print 0 to that number"); scanf("%d",&last_no); printf("\n"); while(i>last_no) { printf("%d\n",i); i++; } getch(); } //poo.papule
#include <iostream> using namespace std; int main() { int i=1; do { if( i%2 ) cout<<i<<" "; } while( ++i<100 ); cout<<endl<<endl; return(0); }
CLS PRINT "PROGRAM: Print squares of all even numbers from 1 to 20" PRINT PRINT "number", "squared" PRINT FOR number% = 1 TO 20 IF number% MOD 2 = 0 THEN PRINT number%, number% * number% END IF NEXT END
The following cases are all possible:- program without any for and while- program without for- program without while- program with both for and while
10 N = 1020 WHILE N < 5130 S = N^2 : Print N, S40 N = N + 150 WEND