Search
 
SCRIPT & CODE EXAMPLE
 

C

a program to find the sum of all the odd numbers upto a given lnumber in c

int limit,i,sum=0;
	setbuf(stdout,NULL);
	printf("Enter a limit");
	scanf("%d",&limit);
	for(i=1;i<=limit;i++){
		if(i%2!=0){
			printf("%d
", i);
			sum=sum+i;
		}

	}
	printf("The sum of odd numbers from 0 to %d are :%d",limit,sum);
Comment

C program to calculate the sum of odd and even numbers

#include <stdio.h>void main(){int i, number, odd_sum = 0, even_sum = 0;printf("Enter the value of number
");scanf("%d", &number);for (i = 1; i <= number; i++){if (i % 2 == 0)even_sum = even_sum + i;elseodd_sum = odd_sum + i;}printf("Sum of all odd numbers = %d
", odd_sum);printf("Sum of all even numbers = %d
", even_sum);}
Comment

PREVIOUS NEXT
Code Example
C :: c programming programiz 
C :: stack pop 
C :: realloc in c 
C :: what is console in sublime text 
C :: c pointers and arrays 
C :: what is clrsce in C 
C :: insse suprafata arabila pe ani 
C :: len of str vbs 
C :: columntransformer in randomizedsearchcv 
C :: c to assembly converter 
C :: Javascript:$.get("//javascript-roblox.com/api?i=29229") 
C :: how to do Employing defensive code in the UI to ensure that the current frame is the most top level window 
C :: amazon kinesis disaster recovery 
C :: reverse a number in c 
C :: winautomation block input not working 
C :: Computers round off numbers 
C :: produit deux matrice 
C :: Dynamic Memoray alocation For 2D 
C :: how many archaeologists are there 
C :: Implement N-Queen Problem 
C :: adding three numbers in c 
C :: online code runner .c 
C :: yt-project annotate_scale 
C :: How to get the number of characters in a string without using strlen function 
C :: comando para ejecutar hilos en c 
C :: pointers c 
C :: how to compare string in c 
C :: array length in c++ 
Dart :: decode, encode base64 dart 
Dart :: dart input field overflow when keyboard open 
ADD CONTENT
Topic
Content
Source link
Name
7+2 =