C++ program to find sum of series 1 + 2 + 3 +……+ n
#include<iostream.h> #include<conio.h> void main() { clrscr(); int i,n,sum=0; cout<<“1+2+3+……+n”; cout<<“nEnter the value of n:”; cin>>n; for(i=1;i<=n;++i) sum+=i; cout<<“nSum=”<<sum; getch(); }
#include<iostream.h> #include<conio.h> void main() { clrscr(); int i,n,sum=0; cout<<“1+2+3+……+n”; cout<<“nEnter the value of n:”; cin>>n; for(i=1;i<=n;++i) sum+=i; cout<<“nSum=”<<sum; getch(); }
Hello friends, after enjoying the festival of diwali I am back again to write something for you. Many visitors asked me that from where they can download turbo c++ for windows xp. So i thought that i should do something to help them. In this post i am giving you the link to download the compiler …
Turbo C++ for Windows XP – How to Download and Install Read More »
Here you will get program for armstrong number in C. Armstrong number is n digits number whose sum of digits raised to power n is equal to itself. For example: 371 is armstrong number because 33 + 73 + 13 = 27 + 343 +1 = 371. Program for Armstrong Number in C #include<stdio.h> #include<math.h> int main() …
Here you will get program for armstrong number in C++. A number whose sum of digits raised to power n is equal to itself is called armstrong number. Here n is the total digits in the number. For example, 153 is armstrong number as 153 = 13 + 53 + 33 = 1 + 125 +27. Program …
Here you will learn how to reverse number in C. #include<stdio.h> int main() { long n,rev=0,d; printf(“Enter any number:”); scanf(“%ld”,&n); while(n!=0) { d=n%10; rev=(rev*10)+d; n=n/10; } printf(“The reversed number is %ld”,rev); return 0; } Output Enter any number:16789 The reversed number is 98761
Here you will get program to reverse number in C++. #include<iostream> using namespace std; int main() { long n,rev=0,d; cout<<“Enter any number:”; cin>>n; while(n!=0) { d=n%10; rev=(rev*10)+d; n=n/10; } cout<<“The reversed number is “<<rev; return 0; } Output Enter any number:12674 The reversed number is 47621
#include<iostream.h>#include<conio.h>void main(){ clrscr(); //to clear the screen int i,j,k,n; cout<<“How many lines?”; cin>>n; n*=2; for(i=0;i<n;i+=2) { cout<<“n”; for(j=n;j>i;j-=2) cout<<” “; for(k=0;k<=i;++k) cout<<“*”; } getch(); //to stop the screen}
#include<iostream.h>#include<conio.h>void main(){ clrscr(); //to clear the screen int i,j,k,n; cout<<“How many lines?”; cin>>n; n*=2; for(i=0;i<n;i+=2) { cout<<“n”; for(j=1;j<i;j+=2) cout<<” “; for(k=n-1;k>i;–k) cout<<“*”; } getch(); //to stop the screen}