#include <iostream>
using namespace std;
int main()
{
int n;
int a=0;
int sum=0;
cin>>n;
for(int i=1; i<=n; i++)
a++;
if(a%2==1)
cout<<a<<endl;
sum+=a;
}
cout<<sum<<endl;
return 0;
Copyright © 2024 SCHOLAR.TIPS - All rights reserved.
Answers & Comments
#include <iostream>
using namespace std;
int main()
{
int n;
int a=0;
int sum=0;
cin>>n;
for(int i=1; i<=n; i++)
{
a++;
if(a%2==1)
{
cout<<a<<endl;
sum+=a;
}
}
cout<<sum<<endl;
return 0;
}