English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

2006-10-09 01:03:04 · 9 answers · asked by anjani_k_chowdary 1 in Computers & Internet Programming & Design

9 answers

There is an interesting alternative to certain kinds of conditional statement which are mostly the same but with just a small difference. You can write a conditional assignment like:

a = b + c + (e < 0 ? f : g) + h;

which means:

if (e < 0) a = b + c + f + h;
else a = b + c + g + h;

Some experienced C programmers say this is the most ghastly feature of C and you should hardly ever use it. Others claim that it is the very thing for keeping your code compact, non-repetitive and instantly understandable. So, make up your own mind.

2006-10-09 06:04:57 · answer #1 · answered by Anonymous · 0 0

There are two types of conditional structure 1) Selection and 2) Iteration or Repetition.
the "if" structure is used when one alternative is to be chosen from one or two alternatives and "switch-case" is to be chosen when only one alternative is to be chosen from multiple alternatives. Their general forms are :
1) if ( cond_exp )
statement(s)
[ else
statement(s) ]
Example : if (num1>0) printf("%d is positive", num1);
2) switch ( expression)
{case item1 : action1; break;
case item2 : action2;break
....
case item3: action3; break;
default : default action;
}
Example : switch (choice)
{ case 'C' : printf('Circle");
case 'R' : printf("Rectangle");
default : printf("Invalid Choice");
}

For repetition or loop C provides
1) for (initi_expr; cond_expr; modi_expr)
statement(s)
Example : for (i=1;i>=10;i++) printf("%d", i);

2) while (cond_expr)
statement(s)
Example : while ( i<=10) { printf("%d",i); i++; }

3) do
statement(s)
while (cond_expr);
Example : do { printf("%d",i); i++; } while (i<=10);

2006-10-09 18:49:42 · answer #2 · answered by Dhara D 1 · 0 0

Condition statements in c are of three types they r (if,do,while) they r used to check a specific condition or to verify;
eg:
if(x<5)
do the following
.........
else
don't do it

2006-10-09 01:06:53 · answer #3 · answered by Kris 1 · 0 0

C
C is a general purpose Programming Language. C has proven to be a pleasant, powerful, and versatile language for a wide variety of Programs. Many of the modern languages like C++, Visual C++, Java, JavaScript, etc. are based on C Language. Therefore, not knowing this Language is considered a handicap. 90% of UNIX Operating System is written in C Language.

SALIENT FEATURES

C is a general purpose Structured Language that is powerful, efficient and compact.
C is combination of High level language and Assembly language that's why it's good for man & assembler.
C is a robust language whose rich set of built-in function and operator can be used to write any complex program.
C is portable language.
C provides a variety of data types.
In addition, there is a hierarchy of derived data types created with pointers, arrays, structures and unions.
Programming in C is efficient & fast because of its datatypes and various operator.
APPLICATION

90% of UNIX Operating System is written in C Language.
TOPICS COVERED

Basic Structure of C, Constants, Variables, Data types & Keywords, Operators, Expression, Conditional Operators.
Decision, Loop & Switch Control Statement.
Array's & String Handling, Creating Functions in C.
Introduction to Pointers in C.
Passing Pointers as Arguments to Function.
Structure, Union. File Handling Dynamic Allocation of Memory.
Introduction To Linked List Basics.
C ++

C++ is a Object Oriented Programming Language that is powerful, efficient and compact. It includes concepts like Polymorphism, Dynamic Binding, Data hiding, Operator encapsulation and inheritance, which are to observed in C. User defined Objects (instances) can be reused with and without modifications to generate newapplication. This reduces coding to greater extends.

SALIENT FEATURES

For file accessing, you can use file objects to open or manipulate a file.
C++ is a Robust language whose rich set of built-in function and operator can be used to reduce complexity of program.
C++ is also a Portable language.
APPLICATION

Complex real-time System.
Simulation and Modeling.
Object-oriented database.
Hypertext, hypermedia and expert text.
Neural networks and parallel programming.
Communication System.
TOPICS COVERED

Introduction to Object Oriented Programming (C++).
Tokens, expression, data types & control structure.
Introduction to Classes, Objects, Constructor & Deconstructor.Functions in C++.
Function overloading, operator overloading.
Inheritance, multiple & multilevel inheritance.
Introduction to virtual functions, classes & polymorphism.
File operations using fstream classes.
Exception Handling.
Introduction to Templates.

2006-10-10 02:19:21 · answer #4 · answered by Krishna 6 · 0 0

1.if (condition)
{
}
2.if(condition)
{
}else
{
}

2006-10-12 19:15:00 · answer #5 · answered by Anonymous · 0 0

Ever heard of a little word called "please"? It can instantly turn an otherwise rude instruction into a polite request!

Rawlyn.

2006-10-09 01:18:16 · answer #6 · answered by Anonymous · 0 0

Try this out
http://www.unfactored.org/~jsh/sw/jade/jade_135.html

2006-10-09 01:10:56 · answer #7 · answered by Yashwant 2 · 0 0

a)
if (boolen expretion)
{
// code should go here
}

B)
if (boolen expretion)
{
// code should go here
}
else
{
// code should go here
}

2006-10-09 01:55:14 · answer #8 · answered by Rami 5 · 0 0

(i) if
if(condn)
{
stmt;
}

(ii)while
while(condn)
{
stmt
}

(iii) for
for(var decln;condn;increment)
{
}

2006-10-09 01:26:43 · answer #9 · answered by manju r 1 · 0 0

fedest.com, questions and answers