Answer to Question #304607 in C for Dishik

Question #304607

Rahul wants to display the n terms of odd natural number and calculate their sum. Help him



to develop a program in C to perform the task using for loop.

1
Expert's answer
2022-03-02T01:17:05-0500
#include <stdio.h>

int main() {
  int n;
  scanf("%d", &n);
  int sum = 0;
  for (int i = 1; i <= n; i++) {
    sum = sum + i;
  }
  printf("%d", sum);
  return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS