C Program I
C Program I
1. Definec:
*Cisa structuredprogramming language.
*cwasdevelopedin1970sbyDennisRitchieatbelltelephonelaboratories
2. Whatarecharacterset?
1.lette
rs
2.digit
s
3. specialcharacters
4. whitespace
3. Definec tokens:
Thesmallestindividualunitsareknownasctokens.
4. Defineconstant:
Constantsarefixedvaluesthatdonotchangeduringtheexecutionoftheprogram.
5. Whatisidentifier?
Identifiers are referring to the names of variables, functions and arrays.
These are theuser -defined names.
6. Definestring constants:
Astringconstantisasequenceof characterenclosedindoublequotes.
Example: “hello”
7. Whatisvariable?
Avariableis datanamethatmaybe usedtostore thevalue.
8. Definedatatypeandtheirtypes:
Clanguage isrich in itsdata type.ThereareThreetypes:
Primaryorfundamentaldatatyp
e Derived data type
Userdefineddatatype
9. Definevoid:
Void isanemptydata type. Itreturns nothing.The voidtype hasnovalue.
10. Defineoperators:
Anoperatorisasymbolthatistoperformmathematicalorlogicalmanipulation.Itis
used in program to manipulate data and variables.
11. Definetypeconversion:
CS3251_PIC
Theoperandsaredifferenttypesintheexpression.Thelowertypeisautomatically
converted to the higher type before the operation proceeds.
CS3251_PIC
13. DefinetypecasteOperators:
The process of such local conversion of variable is known as casting value or type
modifier ortype caste operator.
14. Defineexpressions:
The combination of operand and operators form the expression. The operand may
be variableor constants.
15. Whatarethevarioustypesofoperators? C
supports the following types of operators
Unary
Unary Plus +
UnaryMinus-
Increment ++
Decrement --
Binary
Arithmetic +,-,*,/,%
Relational<,>,<=,>=,
==,!= Logical &&,||,!
Bitwise&,|,^,<<
,>> Assignment
=
Shorthandassignment+=, -=,*=,/=,%=
Ternary
?:
Special
Sizeof(), *.->
17. WriteanytwopreprocessordirectivesinC
Preprocessor directive instructions are used to instruct the preprocessor
to expand/translate the source program before compilation
Thetwotypesofpreprocessordirectivesare,
#define to define Macro , Global constant
#include to include library files
18. ListdifferentdatatypesavailableinC
Data types are used to specify the type of a variable. In c, the data types are
classified into 3 category. They are,
PrimaryorBuilt-in:int,char,float
Derived : array, enum,
pointer User defined :
function, structure
CS3251_PIC
19. WriteaC programto findfactorial ofa givennumberusing Iteration
voidmain()
{
int
N=5,I,fact=1;
for(i=1;i<=N;i
++)
fact=fact*i;
printf(―Thefactorialvalueof%dis=%d‖,N,fact);
}
21. Whatisthevariable?Illustratewithanexample
- Variableisanamedstoragearea
- Usedtoassignanameto a value
- To declare a variable, we need to specify the data type of the value and the
variablename
Datatypevariable_name;
- Example
int reg;floatavg;
22. Definestaticstorageclass
- Storageclassspecifiesthevisibility&lifetimeof avariable
- Staticstorageclassinitializesavariableto0.
- Longerlifetime–Existsthroughouttheexecutionofprogram
- Visibilitytoall-Anyfunctioncanaccessthevariable-Sharedbyall
1. Explainthedecisionmakingstatementincwithexampleprograms.
2. Explaintheloopingstatementincwithexampleprograms.
3. ExplainoperatorsinC
4. Explainpreprocessordirective.
5. ExplainindetailaboutProgrammingParadigm
6. ExplaintheapplicationsofCLanguage
8. ExplainindetailabouttheDatatypes
9. ExplainindetailabouttheCTokens
CS3251_PIC