Welcome to Scribd, the world's digital library. Read, publish, and share books and documents. See more ➡
Standard view
Full view
of .
×
0 of .
Results for:
P. 1
BC0034 C Programing

# BC0034 C Programing

Ratings: (0)|Views: 118|Likes:

### Availability:

See More
See less

12/19/2011

pdf

text

original

Name:

Rajat Chowdhry
Roll Number:

520810922
Learning Centre:

2017
Subject:
Programming With C
Assignment No.:

1
Date of Submission at the Learning Centre:
19
th
Dec,2008

Ques.

1

What is conditional operator? Using conditional operator find a smallest numberamong two numbers.Ans.
The

Conditional operator (ternary

operator) pair “?:” is available in C to constructconditional expressions of the formexpr1?expr2:expr3where expr1, expr2, expr3 are expressions.The operator ? : works as follows: expr1 is evaluated first. If it isnonzero(true), then the expression expr2 is evaluated and becomes thevalue of the expression. If expr1 is false, expr3 is evaluated and its value becomes the value of the expression. For example, consider the followingstatement:a=100; b=200;c=(a>b)?a:b;In this example, c will be assigned the value of b. This can be achievedusing the if..else statement as follows:if(a>b)c=a;elsec=b;
Ques. 2 Explain different types of constants.Ans.
Constants in C refer to fixed values that do not change during the execution of a program. C supports several types of constants.
1.INTEGER CONSTANTS2.REAL CONSTANTS3.CHARACTER CONSTANTS4.STRING CONSTANTS5.BACKSLASH CHARACTER CONSTANTS

1.Integer Constants :
An integer constant refer to sequence of digits. There arethree types of integers, namely
.
Examples:
“95723”, “-325”, “0X5B”, “7685784L”
2.Real Constants :
The number containing fractional parts like 45.67 are calledreal(or floating point) constants
Examples:
“0.001”, “-9.4”, “-1.3E-2”, “04e4”, “12e-2”
3.Character Constants :
A single character constant(or single character constant)contains a single character enclosed within a pair of single quote marks.
Example:
“X”, “;”
4.String Constants :
A string constant is a sequence of character enclosed withindouble quotes. The character may be letters, number, special, characters and blank space.
Example:
“Hello!”, “1947”, “5+3”
5.Backslash Character constants :
C supports some special backslash character constants that are used in output functions. These character combinations are called
escape sequences. Example:
“\b”, “\n”, “\t”, “\f”
Ques. 3 Explain pre increment and post increment operator with an example.Ans
.
They both increment the variable. But the value returned by the pre-incrementoperator is the value of the variable
after
it has been incremented, while the valuereturned by the post-increment operator is the value
before
it has been incremented.
For example:
int a = 1;int b = ++a;// Now a is 2 and b is also 2.

## Activity (1)

### Showing

AllMost RecentReviewsAll NotesLikes