by Dinesh Thakur
Category: Control Structures

Let us use variables m and n to represent two integer numbers and variable r to represent the remainder of their division, i. e., r = m % n. Euclid's algorithm to determine the GCD of two numbers m and n is given below and its action is illustrated form= 50 and n = 35.

by Dinesh Thakur
Category: Control Structures

A program to determine the sum of digits of a given non-negative integer number using a while loop is presented in Program. The program segment given below does the same thing using a do...while loop.

by Dinesh Thakur
Category: Control Structures

1. if income is less thn, 1,50,000 then no tax

2. if taxable income is in the range 1,50,001-300,000 then charge 10% tax

3. if taxable income is in the range 3,00,001-500,000 then charge 20% tax

4. if taxable income is above 5,00,001 then charge 30% tax.

by Dinesh Thakur
Category: Control Structures

The program segment given below accepts a character from the keyboard and prints the name of the corresponding color, e. g., if the user enters character R, it prints Red. However, it handles only three colors, namely, red, green and blue.

by Dinesh Thakur
Category: Control Structures

Let us use variables dd,mm and yy (all of type int)to represent the day, month and year in a given date. The given date is valid only if year (yy)is non-zero, month (mm)is in the range 1 to 12 and day of month (dd) is in the range 1 to mdays, the number of days in a given month mm. An algorithm to determine the validity of a given date is given below.

by Dinesh Thakur
Category: Control Structures

As the name indicates, the prime factors of a given number are its factors that are also prime numbers, e.g., prime factors of 30 are 2, 3 and 5 but not 1, 6, 10, 15 and 30. One or more prime factors of a given number may repeat, e. g., prime factors of 120 are 2, 2, 2, 3 and 5.

by Dinesh Thakur
Category: Control Structures

switch statement is generally best to use when you have more than two conditional expressions based on

a single variable of numeric type. For instance, rather than the code

by Dinesh Thakur
Category: Control Structures

C program to encrypt text using one of the simplest ciphers known as the "Caesar cipher." In this encryption scheme, we shift all characters by a given offset. For example, if we use an offset of 4, every occurrence of 'A' will be replaced by 'E', every occurrence of 'B' will be replaced by 'F', and so forth. The encrypted text can be decrypted by using the reverse process if know the offset used for the encryption.

About Dinesh Thakur

Dinesh Thakur holds an B.SC (Computer Science), MCSE, MCDBA, CCNA, CCNP, A+, SCJP certifications. Dinesh authors the hugely popular Computer Notes 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.

Basic Courses

Advance Courses