## C Program Find the Result of a student in SSC Examination

by Dinesh Thakur Category: Control Structures

Consider that we wish to determine the result of a student in the SSC (Secondary School Certificate) examination, which has six subjects: four of 100 marks each and two of 150 marks each.

## C program Test for whitespace

by Dinesh Thakur Category: Control Structures

A character is a whitespace if it is one of the following characters: blank space (' '), newline ('\n'), horizontal tab ('\t'), carriage return ('\r'), form feed ('\f') or vertical tab ('\v'). The if statement given below tests whether the given character ch is equal to one of these characters using logical or (||) operator and prints an appropriate message.

## C Program for print a name of color that start with a given character

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.

## C Program for print a given digit as a word

by Dinesh Thakur Category: Control Structures

The program segment given below accepts an integer number in variable digit of type int from the keyboard and if it is a single digit number (0-9), it displays the word corresponding to it;

## C Program for Simple Calculator

by Dinesh Thakur Category: Control Structures

Let us use variables a and b of type float to represent two operands, variable c of type float to represent the result and variable op of type char to represent the operator. In the program given below, an expression of the form a op b is first accepted from the keyboard and a switch statement is used to evaluate the result.

## C Program Find The Larger between Two Numbers

by Dinesh Thakur Category: Control Structures

large= a> b? a : b;

This example illustrates how a conditional expression can be used to assign one of two alternative values to a variable depending on the outcome of some condition. As the conditional expression operator has higher precedence than the assignment operator, the above assignment statement is equivalent to

## C Program Find The Days in February

by Dinesh Thakur Category: Control Structures

The if-else statement given below uses the leap year test to determine the number of days in February.

## 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.

## Block Statements in the if Statement

by Dinesh Thakur Category: Control Structures

Often we wish to perform more than one operation when the condition in an if statement evaluates as true and/or false as shown in Fig. In such situations, we use block statements (also called compound statements) within the if statement.

## Write a C program for a menu driven program which has following options:

by Dinesh Thakur Category: Control Structures

1. Factorial of a number.
2. Prime or not
3. Odd or even
4. Exit

Once a menu item is selected the appropriate action should be taken and once this action is finished, the menu should reappear. Unless the user selects the 'Exit' option the program should continue to work.

## Find the efficiency of the worker.

by Dinesh Thakur Category: Control Structures

## Write a C program to display a table of squares and cubes.

by Dinesh Thakur Category: Control Structures

In this example, the initial and final values of loop variable i (of type int) are 1 and 10, respectively. The increment expression, i += 1, increases the value of i by 1. Thus, i assume values 1, 2, 3, 4 and 5.

## Explain control statements those are used in C programming language

by Dinesh Thakur Category: Control Structures

In some situations we may have to change the order of execution of statements based on certain conditions , or repeat a group of statements until certain specified conditions are met. For these situation C provides decision making statements also know as control statements. C has following control statements:

## What is the difference between 'for' and 'while' loops

by Dinesh Thakur Category: Control Structures

For loop: When it is desired to do initialization, condition check and increment/decrement in a single statement of an iterative loop, it is recommended to use 'for' loop.

## Define iteration Statements

by Dinesh Thakur Category: Control Structures

C has looping , in which a sequence of statements are executed until some conditions for termination of the loop are satisfied.

## Why to avoid goto in C

by Dinesh Thakur Category: Control Structures

C has GOTO statement but one must ensure not to use too much of goto statement in their program because its functionality is limited and it is only recommended as a last resort if structured solutions are much more complicated. First let us see what the goto statement does, its syntax and functionality. The goto is a unconditional branching statement used to transfer control of the program from one statement to another.

## Write a program in C programming language to print weekdays using switch statement

by Dinesh Thakur Category: Control Structures

## What are the limitations with switch statement

by Dinesh Thakur Category: Control Structures

Switch statement is a powerful statement used to handle many alternatives and provides good presentation for C program. But there are some limitations with switch statement which are given below:

## When is a switch statement better than multiple if statements

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

## is a default case necessary in a switch statement

by Dinesh Thakur Category: Control Structures

No, but it is not a bad idea to put default statements in switch statements for error- or logic-checking

purposes. For instance, the following switch statement is perfectly normal:

Page 3 of 4

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.

Related Articles