Welcome to Scribd, the world's digital library. Read, publish, and share books and documents. See more ➡
Download
Standard view
Full view
of .
Add note
Save to My Library
Sync to mobile
Look up keyword
Like this
1Activity
×
0 of .
Results for:
No results containing your search query
P. 1
BC0034 C Programing

BC0034 C Programing

Ratings: (0)|Views: 118|Likes:
Published by gurugabru

More info:

Published by: gurugabru on Dec 19, 2011
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as PDF, DOC, TXT or read online from Scribd
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
decimal, octal and hexadecimal 
.
 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.

You're Reading a Free Preview

Download
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->