SlideShare a Scribd company logo
OCS752 − Introduction to C Programming VII Semester EEE
Dept. of CSE Dhanalakshmi College of Engineering 1
DHANALAKSHMI COLLEGE OF ENGINEERING
Tambaram, Chennai
Department of Computer Science and Engineering
OCS752 INTRODUCTION TO C PROGRAMMING
Year / Sem : IV / VII
2 Marks Q & A
OCS752 − Introduction to C Programming VII Semester EEE
Dept. of CSE Dhanalakshmi College of Engineering 2
UNIT – I
INTRODUCTION
Structure of C program – Basics: Data Types – Constants – Variables – Keywords – Operators –
Precedence and Associativity – Expressions – Input/Output statements – Assignment statements –
Decision making statements – Switch statement – Looping statements – Pre processor directives –
Compilation process – Exercise programs: Check whether the required amount can be withdrawn based
on the available amount – Menu-driven program to find the area of different shapes – Find the sum of
even numbers
PART – A
1. What are the different data types in C? (A/M – 14, N/D – 16)
Data types in C
1) Character
2) Integer
3) Floating point
4) Double
2. What are Keywords? (A/M – 15)
Keywords are reserved words with a predefined meaning. Keywords are part of the syntax and they
cannot be used as an identifier.
Example: int money;
Here, int is a keyword and money is a variable of type int (integer).
3. List the various input and output statements in C. (A/M – 15, N/D – 15)
Various input and output statements in C
1) Formatted input statement
2) Unformatted input statement
3) Formatted output statement
4) Unformatted output statement
4. What is a variable? Give example. (N/D – 14, A/M – 16)
Variable is a named location in memory where a program can manipulate the data. This location is used
to hold the value of a variable.
Syntax: data_type variable_name = value;
Example: int x = 50, char flag = ‘x’;
OCS752 − Introduction to C Programming VII Semester EEE
Dept. of CSE Dhanalakshmi College of Engineering 3
5. Distinguish between Local variable and Global variable in C.
S. No. Local variable Global variable
1 Local variables are declared inside a function.
Global variables are declared outside a
function.
2
Local variables are recreated when a function
is called.
Global variables are not recreated when a
function is called.
3
Example
main()
{
int local =10; // Local variable
printf(“Local variable = %d”,local);
}
Example
int global=5; // Global variable
main()
{
printf(“Global variable = %d”,global);
}
6. Differentiate unformatted input/output statement from formatted input/output statement.
(A/M – 19)
S. No. Unformatted input/output statement Formatted input/output statement
1 Unformatted input/output transfers the
internal binary representation of the data
directly between memory and file.
Formatted input/output converts the
internal binary representation of the data to
ASCII characters which are written to the
output file.
2
Unformatted input/output statements are
getchar(), putchar(), getch(), putch(), gets()
and puts().
Formatted input/output statements are
scanf( ), fscanf(), printf() and fprintf().
3
Example
#include<stdio.h>
void main()
{
char ch;
ch = getch();
putch(ch);
}
Example
#include<stdio.h>
void main()
{
int a;
scanf(“%d”,&a);
printf(“number=%d”,a);
}
7. What are constants in C? Mention its types. (A/M – 17)
The constants refer to fixed values whose values do not change during its execution. These fixed values
are also called literals.
OCS752 − Introduction to C Programming VII Semester EEE
Dept. of CSE Dhanalakshmi College of Engineering 4
Types of constant
1) Integer constant
2) Floating point constant
3) Character constant
4) String constant
Example
const int LENGTH = 10;
8. What is the use of external storage class? (A/M – 18)
External storage class is used when we have global functions or variables which are shared between two
or more files. ‘extern’ is the keyword used to implement external storage class. Extern stands for external
storage class.
Example
extern int a=10;
9. Distinguish between Break statement and Continue statement. (N/D – 19)
S. No. Break statement Continue statement
1
Break statement is used to terminate the
block and gets the control out of
the switch or loop.
Continue statement is used to get the
control to the next iteration of the loop.
2
Break can appear in both switch and loop
statements.
Continue can appear only in loop
statement.
3
Example
a=0;
while(a>3)
{
if(a==2)
break;
a++;
}
Example
a=0;
while(a>3)
{
if(a==3)
continue;
a++;
}
10. List the various types of C operators. (N/D – 19)
Various types of C operators
1) Arithmetic operators
2) Relational operators
3) Equality operators
4) Logical operators
OCS752 − Introduction to C Programming VII Semester EEE
Dept. of CSE Dhanalakshmi College of Engineering 5
5) Unary operators
6) Assignment operators
7) Comma operators
8) Conditional operator
9) Bitwise operators
10) Sizeof operators
11. What is preprocessor directive? (A/M – 18, A/M – 19)
Preprocessor directive is a macro processor. It is used automatically by the C compiler to transform the
program before actual compilation.
Example
#define max 10
12. Differentiate While statement from Do...While statement. (A/M–16, N/D–17)
S. No. While Do...while
1
Executes the statements within the
while block, if only the condition is
true.
Executes the statements within the while
block at least once, even the condition is
false.
2
The condition is checked at the
starting of the loop.
The condition is checked at the end of the
loop.
3 It is an entry controlled loop. It is an exit controlled loop.
13. List the rules to be followed in naming an identifier. (A/M – 16)
Rules to be followed in naming an identifier
1) First letter should be an alphabet.
2) Numbers and alphabets are permitted.
3) Mixing of lower case and upper case are allowed.
4) No special symbols are permitted except underscore ( _ ).
5) Keywords are not permitted.
14. Write any four escape sequences in C. (A/M – 13)
Escape sequences in C
1) n – new line
2) t – tab
3) a – alert
4) 0 – null
OCS752 − Introduction to C Programming VII Semester EEE
Dept. of CSE Dhanalakshmi College of Engineering 6
15. Write a C program to find the sum of even numbers.
#include<stdio.h>
void main()
{
int i, n, sum;
sum = 0;
printf("Enter the Number : ");
scanf("%d",&n);
for(i=1; i<=n; i++)
{
if(i%2==0)
sum=sum+i;
}
printf("Sum of all Even Integers is %d",sum);
}
Output:
Enter the Number : 10
Sum of all Even Integers is 30
16. Mention the various decision making statements in C.
Various decision making statements in C
1) if statement
2) if...else statement
3) nested if statement
4) switch statement
5) nested switch statement
17. Write a note on main() in C.
Every c program must have only one main() function. The program execution starts from main()
function. The empty parenthesis () indicates that the main has no arguments.
18. What is the use of sizeof() operator in C? (N/D – 17)
The sizeof() operator is used to find the amount of memory allocated to a variable. Memory size differs
based on the data type.
Example:
sizeof(char); // it returns1
sizeof(int); // it returns 4
sizeof(float); // it returns 4
sizeof(double); // it returns 8
OCS752 − Introduction to C Programming VII Semester EEE
Dept. of CSE Dhanalakshmi College of Engineering 7
19. Define – Compilation
Compilation is defined as the processing of source code files to create an object file. The compiler
produces machine language instructions that correspond to the compiled source code file.
20. List the various input and output statements in C. (A/M – 15)
Various input and output statements in C
1) gets()
2) getch()
3) getchar()
4) scanf()
5) puts()
6) putch()
7) putchar()
8) printf()

More Related Content

What's hot

Basic structure of C++ program
Basic structure of C++ programBasic structure of C++ program
Basic structure of C++ program
matiur rahman
 
Introduction to Input/Output Functions in C
Introduction to Input/Output Functions in CIntroduction to Input/Output Functions in C
Introduction to Input/Output Functions in C
Thesis Scientist Private Limited
 
Function C programming
Function C programmingFunction C programming
Function C programming
Appili Vamsi Krishna
 
COCOMO MODEL 1 And 2
COCOMO MODEL 1 And 2COCOMO MODEL 1 And 2
COCOMO MODEL 1 And 2
Awais Siddique
 
Function in c
Function in cFunction in c
Function in c
savitamhaske
 
User defined functions in C programmig
User defined functions in C programmigUser defined functions in C programmig
User defined functions in C programmig
Appili Vamsi Krishna
 
Functions in c language
Functions in c language Functions in c language
Functions in c language
tanmaymodi4
 
File Handling and Command Line Arguments in C
File Handling and Command Line Arguments in CFile Handling and Command Line Arguments in C
File Handling and Command Line Arguments in C
Mahendra Yadav
 
FINAL PAPER FP301 OBJECT ORIENTED PROGRAMMING
FINAL PAPER FP301 OBJECT ORIENTED PROGRAMMINGFINAL PAPER FP301 OBJECT ORIENTED PROGRAMMING
FINAL PAPER FP301 OBJECT ORIENTED PROGRAMMINGAmira Dolce Farhana
 
Data type in c
Data type in cData type in c
Data type in c
thirumalaikumar3
 
Storage class in c
Storage class in cStorage class in c
Storage class in c
kash95
 
Programming Fundamentals Functions in C and types
Programming Fundamentals  Functions in C  and typesProgramming Fundamentals  Functions in C  and types
Programming Fundamentals Functions in C and types
imtiazalijoono
 
358 33 powerpoint-slides_2-functions_chapter-2
358 33 powerpoint-slides_2-functions_chapter-2358 33 powerpoint-slides_2-functions_chapter-2
358 33 powerpoint-slides_2-functions_chapter-2
sumitbardhan
 
Constructors and Destructors
Constructors and DestructorsConstructors and Destructors
Constructors and Destructors
Dr Sukhpal Singh Gill
 
Variables in C Programming
Variables in C ProgrammingVariables in C Programming
Variables in C Programming
programming9
 
Functions in c
Functions in cFunctions in c
Functions in c
sunila tharagaturi
 

What's hot (20)

Basic structure of C++ program
Basic structure of C++ programBasic structure of C++ program
Basic structure of C++ program
 
Control statement-Selective
Control statement-SelectiveControl statement-Selective
Control statement-Selective
 
Introduction to Input/Output Functions in C
Introduction to Input/Output Functions in CIntroduction to Input/Output Functions in C
Introduction to Input/Output Functions in C
 
Function C programming
Function C programmingFunction C programming
Function C programming
 
COCOMO MODEL 1 And 2
COCOMO MODEL 1 And 2COCOMO MODEL 1 And 2
COCOMO MODEL 1 And 2
 
Function in c
Function in cFunction in c
Function in c
 
User defined functions in C programmig
User defined functions in C programmigUser defined functions in C programmig
User defined functions in C programmig
 
Polymorphism
PolymorphismPolymorphism
Polymorphism
 
Functions in c language
Functions in c language Functions in c language
Functions in c language
 
Manipulators
ManipulatorsManipulators
Manipulators
 
File Handling and Command Line Arguments in C
File Handling and Command Line Arguments in CFile Handling and Command Line Arguments in C
File Handling and Command Line Arguments in C
 
FINAL PAPER FP301 OBJECT ORIENTED PROGRAMMING
FINAL PAPER FP301 OBJECT ORIENTED PROGRAMMINGFINAL PAPER FP301 OBJECT ORIENTED PROGRAMMING
FINAL PAPER FP301 OBJECT ORIENTED PROGRAMMING
 
Data type in c
Data type in cData type in c
Data type in c
 
Storage class in c
Storage class in cStorage class in c
Storage class in c
 
Programming Fundamentals Functions in C and types
Programming Fundamentals  Functions in C  and typesProgramming Fundamentals  Functions in C  and types
Programming Fundamentals Functions in C and types
 
358 33 powerpoint-slides_2-functions_chapter-2
358 33 powerpoint-slides_2-functions_chapter-2358 33 powerpoint-slides_2-functions_chapter-2
358 33 powerpoint-slides_2-functions_chapter-2
 
Constructors and Destructors
Constructors and DestructorsConstructors and Destructors
Constructors and Destructors
 
Variables in C Programming
Variables in C ProgrammingVariables in C Programming
Variables in C Programming
 
C++ Interview Questions
C++ Interview QuestionsC++ Interview Questions
C++ Interview Questions
 
Functions in c
Functions in cFunctions in c
Functions in c
 

Similar to Ocs752 unit 1

VTU PCD Model Question Paper - Programming in C
VTU PCD Model Question Paper - Programming in CVTU PCD Model Question Paper - Programming in C
VTU PCD Model Question Paper - Programming in C
Syed Mustafa
 
answer-model-qp-15-pcd13pcd
answer-model-qp-15-pcd13pcdanswer-model-qp-15-pcd13pcd
answer-model-qp-15-pcd13pcd
Syed Mustafa
 
What is c
What is cWhat is c
What is c
Nitesh Saitwal
 
Programming with c language practical manual
Programming with c language practical manualProgramming with c language practical manual
Programming with c language practical manual
Anil Bishnoi
 
C++ in 10 Hours.pdf.pdf
C++ in 10 Hours.pdf.pdfC++ in 10 Hours.pdf.pdf
C++ in 10 Hours.pdf.pdf
SumitSingh813090
 
Unit i intro-operators
Unit   i intro-operatorsUnit   i intro-operators
Unit i intro-operators
HINAPARVEENAlXC
 
Technical aptitude Test 1 CSE
Technical aptitude Test 1 CSETechnical aptitude Test 1 CSE
Technical aptitude Test 1 CSE
Sujata Regoti
 
CP Handout#5
CP Handout#5CP Handout#5
CP Handout#5
trupti1976
 
UNIT-1 notes(Data Types – Variables – Operations – Expressions and Statements...
UNIT-1 notes(Data Types – Variables – Operations – Expressions and Statements...UNIT-1 notes(Data Types – Variables – Operations – Expressions and Statements...
UNIT-1 notes(Data Types – Variables – Operations – Expressions and Statements...
RSathyaPriyaCSEKIOT
 
Mid term sem 2 1415 sol
Mid term sem 2 1415 solMid term sem 2 1415 sol
Mid term sem 2 1415 sol
IIUM
 
guia de referencia para a linguagem do fabricante CCS info_syntax.pdf
guia de referencia para a linguagem do fabricante CCS info_syntax.pdfguia de referencia para a linguagem do fabricante CCS info_syntax.pdf
guia de referencia para a linguagem do fabricante CCS info_syntax.pdf
SilvanildoManoeldaSi
 
presentation_c_basics_1589366177_381682.pptx
presentation_c_basics_1589366177_381682.pptxpresentation_c_basics_1589366177_381682.pptx
presentation_c_basics_1589366177_381682.pptx
KrishanPalSingh39
 
Programming in C
Programming in CProgramming in C
Programming in C
Nishant Munjal
 
Fundamentals of computer programming by Dr. A. Charan Kumari
Fundamentals of computer programming by Dr. A. Charan KumariFundamentals of computer programming by Dr. A. Charan Kumari
Fundamentals of computer programming by Dr. A. Charan Kumari
THE NORTHCAP UNIVERSITY
 
Aptitute question papers in c
Aptitute question papers in cAptitute question papers in c
Aptitute question papers in c
Pantech ProEd Pvt Ltd
 
cuptopointer-180804092048-190306091149 (2).pdf
cuptopointer-180804092048-190306091149 (2).pdfcuptopointer-180804092048-190306091149 (2).pdf
cuptopointer-180804092048-190306091149 (2).pdf
YashwanthCse
 
Programming in C Presentation upto FILE
Programming in C Presentation upto FILEProgramming in C Presentation upto FILE
Programming in C Presentation upto FILE
Dipta Saha
 
C programing Tutorial
C programing TutorialC programing Tutorial
C programing Tutorial
Mahira Banu
 
C and Data structure lab manual ECE (2).pdf
C and Data structure lab manual ECE (2).pdfC and Data structure lab manual ECE (2).pdf
C and Data structure lab manual ECE (2).pdf
janakim15
 

Similar to Ocs752 unit 1 (20)

VTU PCD Model Question Paper - Programming in C
VTU PCD Model Question Paper - Programming in CVTU PCD Model Question Paper - Programming in C
VTU PCD Model Question Paper - Programming in C
 
answer-model-qp-15-pcd13pcd
answer-model-qp-15-pcd13pcdanswer-model-qp-15-pcd13pcd
answer-model-qp-15-pcd13pcd
 
What is c
What is cWhat is c
What is c
 
Programming with c language practical manual
Programming with c language practical manualProgramming with c language practical manual
Programming with c language practical manual
 
C++ in 10 Hours.pdf.pdf
C++ in 10 Hours.pdf.pdfC++ in 10 Hours.pdf.pdf
C++ in 10 Hours.pdf.pdf
 
Unit i intro-operators
Unit   i intro-operatorsUnit   i intro-operators
Unit i intro-operators
 
Technical aptitude Test 1 CSE
Technical aptitude Test 1 CSETechnical aptitude Test 1 CSE
Technical aptitude Test 1 CSE
 
CP Handout#5
CP Handout#5CP Handout#5
CP Handout#5
 
UNIT-1 notes(Data Types – Variables – Operations – Expressions and Statements...
UNIT-1 notes(Data Types – Variables – Operations – Expressions and Statements...UNIT-1 notes(Data Types – Variables – Operations – Expressions and Statements...
UNIT-1 notes(Data Types – Variables – Operations – Expressions and Statements...
 
Mid term sem 2 1415 sol
Mid term sem 2 1415 solMid term sem 2 1415 sol
Mid term sem 2 1415 sol
 
guia de referencia para a linguagem do fabricante CCS info_syntax.pdf
guia de referencia para a linguagem do fabricante CCS info_syntax.pdfguia de referencia para a linguagem do fabricante CCS info_syntax.pdf
guia de referencia para a linguagem do fabricante CCS info_syntax.pdf
 
presentation_c_basics_1589366177_381682.pptx
presentation_c_basics_1589366177_381682.pptxpresentation_c_basics_1589366177_381682.pptx
presentation_c_basics_1589366177_381682.pptx
 
Programming in C
Programming in CProgramming in C
Programming in C
 
Fundamentals of computer programming by Dr. A. Charan Kumari
Fundamentals of computer programming by Dr. A. Charan KumariFundamentals of computer programming by Dr. A. Charan Kumari
Fundamentals of computer programming by Dr. A. Charan Kumari
 
Aptitute question papers in c
Aptitute question papers in cAptitute question papers in c
Aptitute question papers in c
 
cuptopointer-180804092048-190306091149 (2).pdf
cuptopointer-180804092048-190306091149 (2).pdfcuptopointer-180804092048-190306091149 (2).pdf
cuptopointer-180804092048-190306091149 (2).pdf
 
Sample paper i.p
Sample paper i.pSample paper i.p
Sample paper i.p
 
Programming in C Presentation upto FILE
Programming in C Presentation upto FILEProgramming in C Presentation upto FILE
Programming in C Presentation upto FILE
 
C programing Tutorial
C programing TutorialC programing Tutorial
C programing Tutorial
 
C and Data structure lab manual ECE (2).pdf
C and Data structure lab manual ECE (2).pdfC and Data structure lab manual ECE (2).pdf
C and Data structure lab manual ECE (2).pdf
 

Recently uploaded

Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
Sectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdfSectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdf
Vivekanand Anglo Vedic Academy
 
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptxMARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
bennyroshan06
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
EverAndrsGuerraGuerr
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
Sandy Millin
 
The Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve ThomasonThe Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve Thomason
Steve Thomason
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
Atul Kumar Singh
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
JosvitaDsouza2
 
Fish and Chips - have they had their chips
Fish and Chips - have they had their chipsFish and Chips - have they had their chips
Fish and Chips - have they had their chips
GeoBlogs
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
MysoreMuleSoftMeetup
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
Jisc
 
How to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS ModuleHow to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS Module
Celine George
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
TechSoup
 
Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
Anna Sz.
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
Special education needs
 
Ethnobotany and Ethnopharmacology ......
Ethnobotany and Ethnopharmacology ......Ethnobotany and Ethnopharmacology ......
Ethnobotany and Ethnopharmacology ......
Ashokrao Mane college of Pharmacy Peth-Vadgaon
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
Vikramjit Singh
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Thiyagu K
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
Delapenabediema
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
Pavel ( NSTU)
 

Recently uploaded (20)

Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
 
Sectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdfSectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdf
 
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptxMARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
 
The Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve ThomasonThe Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve Thomason
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
 
Fish and Chips - have they had their chips
Fish and Chips - have they had their chipsFish and Chips - have they had their chips
Fish and Chips - have they had their chips
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
 
How to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS ModuleHow to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS Module
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
 
Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
 
Ethnobotany and Ethnopharmacology ......
Ethnobotany and Ethnopharmacology ......Ethnobotany and Ethnopharmacology ......
Ethnobotany and Ethnopharmacology ......
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
 

Ocs752 unit 1

  • 1. OCS752 − Introduction to C Programming VII Semester EEE Dept. of CSE Dhanalakshmi College of Engineering 1 DHANALAKSHMI COLLEGE OF ENGINEERING Tambaram, Chennai Department of Computer Science and Engineering OCS752 INTRODUCTION TO C PROGRAMMING Year / Sem : IV / VII 2 Marks Q & A
  • 2. OCS752 − Introduction to C Programming VII Semester EEE Dept. of CSE Dhanalakshmi College of Engineering 2 UNIT – I INTRODUCTION Structure of C program – Basics: Data Types – Constants – Variables – Keywords – Operators – Precedence and Associativity – Expressions – Input/Output statements – Assignment statements – Decision making statements – Switch statement – Looping statements – Pre processor directives – Compilation process – Exercise programs: Check whether the required amount can be withdrawn based on the available amount – Menu-driven program to find the area of different shapes – Find the sum of even numbers PART – A 1. What are the different data types in C? (A/M – 14, N/D – 16) Data types in C 1) Character 2) Integer 3) Floating point 4) Double 2. What are Keywords? (A/M – 15) Keywords are reserved words with a predefined meaning. Keywords are part of the syntax and they cannot be used as an identifier. Example: int money; Here, int is a keyword and money is a variable of type int (integer). 3. List the various input and output statements in C. (A/M – 15, N/D – 15) Various input and output statements in C 1) Formatted input statement 2) Unformatted input statement 3) Formatted output statement 4) Unformatted output statement 4. What is a variable? Give example. (N/D – 14, A/M – 16) Variable is a named location in memory where a program can manipulate the data. This location is used to hold the value of a variable. Syntax: data_type variable_name = value; Example: int x = 50, char flag = ‘x’;
  • 3. OCS752 − Introduction to C Programming VII Semester EEE Dept. of CSE Dhanalakshmi College of Engineering 3 5. Distinguish between Local variable and Global variable in C. S. No. Local variable Global variable 1 Local variables are declared inside a function. Global variables are declared outside a function. 2 Local variables are recreated when a function is called. Global variables are not recreated when a function is called. 3 Example main() { int local =10; // Local variable printf(“Local variable = %d”,local); } Example int global=5; // Global variable main() { printf(“Global variable = %d”,global); } 6. Differentiate unformatted input/output statement from formatted input/output statement. (A/M – 19) S. No. Unformatted input/output statement Formatted input/output statement 1 Unformatted input/output transfers the internal binary representation of the data directly between memory and file. Formatted input/output converts the internal binary representation of the data to ASCII characters which are written to the output file. 2 Unformatted input/output statements are getchar(), putchar(), getch(), putch(), gets() and puts(). Formatted input/output statements are scanf( ), fscanf(), printf() and fprintf(). 3 Example #include<stdio.h> void main() { char ch; ch = getch(); putch(ch); } Example #include<stdio.h> void main() { int a; scanf(“%d”,&a); printf(“number=%d”,a); } 7. What are constants in C? Mention its types. (A/M – 17) The constants refer to fixed values whose values do not change during its execution. These fixed values are also called literals.
  • 4. OCS752 − Introduction to C Programming VII Semester EEE Dept. of CSE Dhanalakshmi College of Engineering 4 Types of constant 1) Integer constant 2) Floating point constant 3) Character constant 4) String constant Example const int LENGTH = 10; 8. What is the use of external storage class? (A/M – 18) External storage class is used when we have global functions or variables which are shared between two or more files. ‘extern’ is the keyword used to implement external storage class. Extern stands for external storage class. Example extern int a=10; 9. Distinguish between Break statement and Continue statement. (N/D – 19) S. No. Break statement Continue statement 1 Break statement is used to terminate the block and gets the control out of the switch or loop. Continue statement is used to get the control to the next iteration of the loop. 2 Break can appear in both switch and loop statements. Continue can appear only in loop statement. 3 Example a=0; while(a>3) { if(a==2) break; a++; } Example a=0; while(a>3) { if(a==3) continue; a++; } 10. List the various types of C operators. (N/D – 19) Various types of C operators 1) Arithmetic operators 2) Relational operators 3) Equality operators 4) Logical operators
  • 5. OCS752 − Introduction to C Programming VII Semester EEE Dept. of CSE Dhanalakshmi College of Engineering 5 5) Unary operators 6) Assignment operators 7) Comma operators 8) Conditional operator 9) Bitwise operators 10) Sizeof operators 11. What is preprocessor directive? (A/M – 18, A/M – 19) Preprocessor directive is a macro processor. It is used automatically by the C compiler to transform the program before actual compilation. Example #define max 10 12. Differentiate While statement from Do...While statement. (A/M–16, N/D–17) S. No. While Do...while 1 Executes the statements within the while block, if only the condition is true. Executes the statements within the while block at least once, even the condition is false. 2 The condition is checked at the starting of the loop. The condition is checked at the end of the loop. 3 It is an entry controlled loop. It is an exit controlled loop. 13. List the rules to be followed in naming an identifier. (A/M – 16) Rules to be followed in naming an identifier 1) First letter should be an alphabet. 2) Numbers and alphabets are permitted. 3) Mixing of lower case and upper case are allowed. 4) No special symbols are permitted except underscore ( _ ). 5) Keywords are not permitted. 14. Write any four escape sequences in C. (A/M – 13) Escape sequences in C 1) n – new line 2) t – tab 3) a – alert 4) 0 – null
  • 6. OCS752 − Introduction to C Programming VII Semester EEE Dept. of CSE Dhanalakshmi College of Engineering 6 15. Write a C program to find the sum of even numbers. #include<stdio.h> void main() { int i, n, sum; sum = 0; printf("Enter the Number : "); scanf("%d",&n); for(i=1; i<=n; i++) { if(i%2==0) sum=sum+i; } printf("Sum of all Even Integers is %d",sum); } Output: Enter the Number : 10 Sum of all Even Integers is 30 16. Mention the various decision making statements in C. Various decision making statements in C 1) if statement 2) if...else statement 3) nested if statement 4) switch statement 5) nested switch statement 17. Write a note on main() in C. Every c program must have only one main() function. The program execution starts from main() function. The empty parenthesis () indicates that the main has no arguments. 18. What is the use of sizeof() operator in C? (N/D – 17) The sizeof() operator is used to find the amount of memory allocated to a variable. Memory size differs based on the data type. Example: sizeof(char); // it returns1 sizeof(int); // it returns 4 sizeof(float); // it returns 4 sizeof(double); // it returns 8
  • 7. OCS752 − Introduction to C Programming VII Semester EEE Dept. of CSE Dhanalakshmi College of Engineering 7 19. Define – Compilation Compilation is defined as the processing of source code files to create an object file. The compiler produces machine language instructions that correspond to the compiled source code file. 20. List the various input and output statements in C. (A/M – 15) Various input and output statements in C 1) gets() 2) getch() 3) getchar() 4) scanf() 5) puts() 6) putch() 7) putchar() 8) printf()