## C program to find numbers whose sum of cubes of individual numbers is that number

Here is an implementation of while loop in C to find numbers whose sum of cubes of individual numbers is that number. You can go a step further and make it so that you accept value of i and n. main(){ int i = 1, a, b, c, n = 1000; printf(“\n Enter a number…

## C program to find circumference and area of a circle from given radius

Here is a simple C program to find circumference and area of a circle from given radius – main(){ float r, pi = 3.1416, c, area; printf(“\nEnter value of radius>> “); scanf(“%f”, &r); while (r > = 0.0){ c = 2*pi*r; area = pi*r*; printf(“\nCircumference = %f”, c); printf(“\nArea = %f”, area); scanf(“%f”, &r) } }

## While Loop in C

Like do-while loop, While loop is the most commonly used looping construct to repeat a process or calculation for a set or collection of inputs or storage based on a condition. It is a looping technique when you want to execute the required process based on a condition for the entire input collection. Below is…

## C program to find the sum of squares of first n natural numbers

Here is a simple C program to find the sum of squares of first n natural numbers using do-while looping construct – main(){ int n, sum =0; printf(“\nInput any integer of your choice>>”); scanf(“%d”,&n); nsave = n; do{ sum += n*n; n–; } while(n > 0); printf(“Sum of squares upto %d = %d \n”, nsave,…

## Do – While Loops in C

Looping constructs is an important programming language technique to repeat a process or calculation for a set or collection of inputs or storage based on a condition. Do – While is a looping technique when you want to execute the required process for at least once and then check the condition for the rest of the…

## Sample C program showing if – else constructs

Below are simple C programs for beginners to learn if-else decision construct. Example 1: Program to check if a number is odd or even main (){ int n; printf(“Please enter any number>> “); scanf(“%d”, &n); if(n % 2 == 0) printf(“\n%d is EVEN \n”, n); else printf(“\n%d is ODD \n”, n); } Example 2: Program…

## C Program to check for leap year

Here is a C program to check for leap year – main () { int year; printf(“Please enter any year as 4 digits>> “); scanf(“%d”, &year); if(year % 4 ==0 && year % 100 !=0 || year % 400 == 0) printf(“%d is a leap year \n”, year); else printf(“%d is not a leap year…