#include<iostream>
using namespace std;
int main()
{
int N;
cout<<"\nHow many numbers?";
cin>>N;
int arr[N];
cout<<"\nEnter the numbers: ";
for(int i=0;i<N;i++)
cin>>arr[i];
int max=arr[0];
for(int i=1;i<N;i++)
if(arr[i]>max)
max=arr[i];
cout<<"\nThe maximum is "<<max;
return 0;
}
if (n%2==0) sum=n/2*(n+1); else sum=(n+1)/2*n;
int n, i; for(n = 1; n <= 5; ++n) { for(i = 1; i <= n; ++i) { printf("%d", n); } }
int total = 0; int n; for( n = 112; n <= 212; ++n) { total += n; } printf("%d\n", total);
void print_evens (size_t n) {for (size_t x=0; x<=n; x+=2) { std::cout << x << std::endl; } }
Yes, you can use for-loop in a C program compiled by Turbo C.
if (n%2==0) sum=n/2*(n+1); else sum=(n+1)/2*n;
#include<iostream> int main() { std::cout << "*******\n" "*******\n" " *****\n" " ***\n" " *\n" " ***\n" " *****\n" "*******\n" "*******\n"; }
#include <iostream> int main() { printf( " *\n***\n *\n" ); return( 0 ); } Output: *****
That factors to (m + n)(r + s) The GCF is 1.
int n, i; for(n = 1; n <= 5; ++n) { for(i = 1; i <= n; ++i) { printf("%d", n); } }
int bitcount (unsigned n) { int bitc= 0; while (n) { ++bitc; n = n&(n-1); } return bitc; }
int total = 0; int n; for( n = 112; n <= 212; ++n) { total += n; } printf("%d\n", total);
main() { int i, n, sum=0; cout<<"Enter the limit"; cin>>n; for(i=0;i<=n;i++) sum=sum+i; cout<<"sum of "<<n<<" natural numbers ="<<sum; getch(); }
There is no such thing as 'the greatest number'. Here is a program in unix to prove it: echo 'for (i=1; i>=0; i= i*2) print i,"\n";' | bc if you want to actually see the output use it this way: echo 'for (i=1; i>=0; i= i*2) print i,"\n";' | bc | less -S
cn = c0 *( 1 + i ) pow n
Print "Type the upper limit (n) ?" Input n K = -1 WHILE K < = n K = K + 2 Sum = Sum + K WEND Print "The sum of all odd numbers up to "; n; "is "; Sum
n plus 15.n plus 15.n plus 15.n plus 15.