## C Program Four digit special perfect square numbers

by Dinesh Thakur Category: Control Structures

The program segment given below prints four-digit special perfect square numbers in which the upper and lower two-digit numbers are perfect squares as well.

## C Program Sum of digits of number repeatedly to obtain a single-digit number

by Dinesh Thakur Category: Control Structures

The program segment given below determines the sum of digits of a given number repeatedly until a single digit number is obtained. For example, 5985 => 27 => 9, where symbol => indicates a digit sum operation. Thus, if digit sum exceeds 9, it is used as a number for subsequent digit sum operations.

## C Program Character test letter, vowel, consonant

by Dinesh Thakur Category: Control Structures

The program segment given below uses a nested if statement to determine whether a given character is a letter or not. In addition, if the given character is a letter, it tests whether it is a vowel or consonant.

## switch Statement in C

by Dinesh Thakur Category: Control Structures

The switch statement allows us to test an expression and depending on its value, execute a statement (or group of statements) amongst several alternatives. It is the most involved statement provided in C language. It uses four keywords, namely, switch, case, default and break. The last two keywords are optional and can be omitted. The general form of this statement is given below and its flowchart is shown in.

## while loop in C

by Dinesh Thakur Category: Control Structures

The while loop is particularly useful when the number of iterations is not known or cannot be determined in advance. The general syntax of the while loop is as follows:

## C Program Reverse digits in an integer number

by Dinesh Thakur Category: Control Structures

The program segment given below obtains a number by reversing the digits in the given number.

## C program for Print a line of dashes

by Dinesh Thakur Category: Control Structures

The for loop given above prints a line of fifty dashes followed by a newline. The for loop uses i as the loop variable whose initial and final values are 0 and 49, respectively (note the < operator in i < 50). The update expression increments the value of i by 1.

## C Program for Print all uppercase letters followed by all lowercase letters on the next line

by Dinesh Thakur Category: Control Structures

In this example, we use two for loops in conjunction with the putchar library function to print all uppercase letters followed by all lowercase letters. The loop variable ch is assumed to be of type char or int. The first for loop prints the uppercase letters as loop variable ch assumes values as ‘A’, 'B’, ... , ‘z’.

## C Program for GCD of Two Integers using Euclid's algorithm

by Dinesh Thakur Category: Control Structures

The Greatest Common Divisor of two positive integers can be calculated iteratively by the following formula known as Euclid's algorithm. You can see that this is a recursive definition with GCD(m,n) defined in terms of GCD(n,m%n).

## C Program division without causing a division by zero error

by Dinesh Thakur Category: Control Structures

While performing a division operation, if the divisor is zero, the division by zero error occurs and program execution halts abruptly. The program segment given below calculates and prints the value of a/b without causing a division by zero error.

Page 4 of 7

Dinesh Thakur holds an B.SC (Computer Science), MCSE, MCDBA, CCNA, CCNP, A+, SCJP certifications. Dinesh authors the hugely popular blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps. For any type of query or something that you think is missing, please feel free to Contact us.

Search Content

Popular Article