Write a program to add natural numbers up to 20 by using for loop in c++ language.
Write a program to add natural numbers up to nth term by using for loop in c++ language. #include <iostream> using namespace std; int main() { int sum =0 ,n ; cout<<"Enter the nth term n = "; cin>>n; for(int i =1;i<=n; i++) { sum =sum +i ;} cout<<"sum of "<<n<<"th term is = "<<sum return 0; } OUTPUT Enter the nth term n = 20 the sum of 20th term is = 210 Write a program that prompts the user to input a positive integer. It should then print the multiplication table of that number.
Comments
Post a Comment
If you have any doubt ,let me know