MSK Technologies

Home
Practice Programs
Java Programs Python Programs Java Quiz
Pages
Python Java Material PLSQL Material
Search A Job

Write a C-program to print sum of even numbers using while loop?

  1. Home
  2. C Language Programs

Write a C-program to print sum of even numbers using while loop?

Write a C-program to print sum of even numbers using while loop


#include <stdio.h>
int main() {
    int x=1,n,sum=0;
    printf("Enter n value ");
    scanf("%d",&n);
    while(x<=n)
    {
        if(x%2==0)
        {
            sum=sum+x;
        }
        x++;
    }
    printf("%d sum is %d",n ,sum);
  
    return 0;
}

Output:

Enter n value 5

5 sum is 6

Enter n value 10
10 sum is 30




More Programs


68 . Write a C-program to print sum of even numbers using while loop
69 . Write a C-program to print sum of odd numbers using while loop
70 . Write a C-program to print sum of even or odd numbers based on the n value using while loop
71 . Write a C-program to print sum of even or odd numbers based on the n value using single while loop
72 . Write a C-program to display table using while loop
73 . Write a C-program to print a to z using while loop
74 . Write a C-program to print ASCII values of a to z using while loop
75 . Write a C-program to print ASCII values of A to Z using while loop
76 . Write a C-program to print ASCII values of Numbers using while loop
77 . Write a C-program to print 1 to 10 values using do while loop
78 . Write a C-program to print 10 to 1 values using do while loop



Apply For The Job

Apply For Job

Java Material

Python Material

PLSQL Material

.Net Material

Java Practice Programs

400 Java Programs

Java Practice Programs

Write a Java program to convert seconds to hour, minute and seconds

Write a java Program to check the given number is Palindrome or not

Write a Java program that takes five numbers as input to calculate and print the average of the numbers

Write a Java Program to Find the sum of the digits of a number

Write a Java program to print ‘Hello World!’ on screen

Python Practice Programs

Write a Python Program to print Palindrome numbers from 1 to 100

Write a python program to open a website using python

Write a Python Program to Check if a Number is Odd or Even.

Write a python program to counting item occurrences

Write a Python program to remove duplicates from a list

Java Quiz

Java Quiz - 20

Java Quiz - 10

Java Quiz - 15

Java Quiz - 17

Java Quiz - 19

Courses
Java Python PLSQL .Net ADO.Net About Us
Quick Links
Daily Use English Sentences Daily General Knowledge General Knowledge Latest Update Inventions and Inventors జనరల్ నాలెడ్జ్ General Knowledge Spoken English Spoken Hindi GK Hindi Telugu Facts Unknown Facts Psychology Facts Motivation Quotes విటమిన్ - సి,డి,ఇ,కె Android
Spiritual
రాధాకృష్ణ భగవద్గీత Motivation Quotes Slokas Talapatra Nidhi ఆధ్యాత్మిక భక్తి ప్రపంచం Sadhguru Sai Motivation Quotes గౌతమ బుద్ధుడు Bhagavad Gita Quotes
Newsletter

Dolor amet sit justo amet elitr clita ipsum elitr est.

© sateeshm, All Right Reserved. Designed By sateeshm
Home Help FQAs