sum of the user input number in cpp with dsa

technical talkiess
0

 


// use the labrarey


#include <iostream>

// using the namespace 

using namespace std;

// ; means end progran line 

// endl means new line 

// \n means new line

// start the program 

int main(){

int n;

  int sum = 0;

int a = 1;

  cout<<"Enter the number:- ";

  cin>>n;

  while(a<=n)

  {

    sum+=a;

    a++;

  }

  cout<<endl;

  cout<<"The sum of the number is "<<sum;

  

}


Tags

Post a Comment

0Comments

Thanks you for commenting your questions. I will see question and respond you.

Post a Comment (0)