// CSE/CE/IT 124 JULY 2015, 2.a. algorithm to inverse the digits of a given integer. Step 1: Start Step 2: Read: NUMBER Step 3: r=0,rev=0
|
|
- Darlene Bradford
- 6 years ago
- Views:
Transcription
1 // CSE/CE/IT 124 JULY 2015, 2a algorithm to inverse the digits of a given integer Step 1: Start Step 2: Read: NUMBER Step 3: r=0,rev=0 Step 4: repeat until NUMBER > 0 r=number%10; rev=rev*10+r; NUMBER=NUMBER/10; Step 5: Write rev Step 6: Exit 3b List and explain the functionality of various Conversion characters (specifiers) for data input in C-language %d int %c char %s character array Explain with example program 4a Given three points (x1, y1), (x2, y2) and (x3, y3) Write a program to find whether they are collinear #include <stdioh> int x1,y1,x2,y2,x3,y3,slope1,slope2,slope3; printf("\n Enter 1st co-ordinate (x1,y1)"); scanf("%d%d",&x1,&y1); printf("\n Enter 2nd co-ordinate (x2,y2)"); scanf("%d%d",&x2,&y2); printf("\n Enter 3rd co-ordinate (x3,y3)"); scanf("%d%d",&x3,&y3); slope1=(y2-y1)/(x2-x1); slope2=(y3-y2)/(x3-x2); slope3=(y3-y1)/(x3-x1); printf("slope1=%d\nslope2=%d\nslope3=%d\n",slope1,slope2,slope3);
2 if(slope1==slope2 slope2==slope3 slope1==slope3) printf("\n Collinear points"); else printf("\n not Collinear points"); Output: Enter 1st co-ordinate (x1,y1)2 4 Enter 2nd co-ordinate (x2,y2)4 6 Enter 3rd co-ordinate (x3,y3)6 8 slope1=1 slope2=1 slope3=1 Collinear points // CSE/CE/IT 124 JULY 2015, 4b- factorial of a given number int n,i,f=1; printf("enter n\n"); scanf("%d",&n); for(i=1;i<=n;i++) f=f*i;
3 printf("factorial=%d\n",f); Explain in your own words // CSE/CE/IT 124 JULY 2015, 5a to grade the results of a class of 100 students int n,i,g; float a[100]; // for 100 students //printf("enter n\n"); //scanf("%d",&n); printf("enter percentage of students\n"); for(i=0;i<100;i++) scanf("%f",&a[i]); for(i=0;i<100;i++) printf("\n%d student grade ",i+1); if(a[i]>=70) printf("distinction\n"); else if(a[i]>=60 && a[i]<70) printf("first class\n"); else if(a[i]>=50 && a[i]<60) printf("second class\n"); else printf("fail\n"); // CSE/CE/IT 124 JULY 2015, 5b arrange the elements in descending order of their magnitude
4 int a[100],n,i,j,t; printf("enter n value\n"); scanf("%d",&n); printf("\nenter array elements\n"); scanf("%d",&a[i]); printf("\nelements before sorting\n"); printf("%d\t",a[i]); for(i=0;i<n-1;i++) for(j=0;j<n-i-1;j++) if(a[j]<a[j+1]) t=a[j]; a[j]=a[j+1]; a[j+1]=t; printf("\nelements after sorting\n"); printf("%d\t",a[i]); // CSE/CE/IT 124 JULY 2015, 6a function that seek a character string passed as argument and converts all lower case characters into their upper case characters for(i=0;str[i]!='\0';i++) if(str[i]!=' ')
5 str[i]=str[i]-32; printf("string upper=%s\n",str); // CSE/CE/IT 124 JULY 2015, 6b using pointers to read an array of integers and print its elements in reverse order int n,i,*p,j,t; printf("enter no of elements\n"); scanf("%d",&n); p=(int*)malloc(n*sizeof(int)); printf("enter array elements\n"); scanf("%d",p+i); printf("elements are\n"); printf("%d\t",*(p+i)); //question print the array elements in revesre order printf("\n Elements in reverse order\n"); for(i=n-1;i>=0;i--) printf("%d\t",*(p+i)); printf("\n"); /* if question is revesre the array elements for(i=0,j=n-1;i<j;i++,j--) t=*(p+i); *(p+i)=*(p+j); *(p+j)=t; printf("%d\t",*(p+i));*/ // CSE/CE/IT 124 JULY 2015, 7a- function exchange to interchange the values of x & y
6 int x,y; void exchange(int*,int*); printf("enter two values\n"); scanf("%d%d",&x,&y); printf("\nbefore swapping %d\t%d\n",x,y); //call by reference exchange(&x,&y); printf("\nafter swapping %d\t%d\n",x,y); void exchange(int *a,int *b) int t; t=*a; *a=*b; *b=t; // CSE/CE/IT 124 JULY 2015, 7b- how can pass pointers to functions Write theory And example program Eg: #include<malloch> int *a,n,i; void read(int *,int); void display(int *,int); printf("enter n value\n"); scanf("%d",&n);
7 a=(int *)malloc(n*sizeof(int)); read(a,n); display(a,n); void read(int *x,int n) int i; printf("\nenter array elements\n"); scanf("%d",x+i); void display(int *x,int n) int i; printf("array elenents\n"); printf("%d\t",*(x+i)); // CSE/CE/IT 124 JULY 2015, 8a Distinguish structure and union 1 2 Structure Structure is a derived data type and Hetrogeneous Structure has members with different data types Syntax: structure <tagname> datatype1 member1; datatype2 member2; datatypen membern; ; Structure members are accessed through structure variable and dot operator In structure each member has separate space in memory Take below example struct student Union Union is a derived data type and Hetrogeneous Union has members with different data types Syntax: union <tagname> datatype1 member1; datatype2 member2; datatypen membern; ; Union members are accessed through Union variable and dot operator In union, all members share the same memory space This is the biggest difference between structure and union
8 int rollno; char gender; float marks; s1; The total memory required to store a structure variable is equal to the sum of size of all the members In above case 7 bytes (2+1+4) will be required to store structure variable s1 union student int rollno; char gender; float marks; s1; In above example variable marks is of float type and have largest size (4 bytes) So the total memory required to store union variable s1 is 4 bytes 3 We can access any member in any sequence s1rollno = 20; s1marks = 900; printf( %d,s1rollno); The above code will work fine but will show erroneous output in the case of union We can access only that variable whose value is recently stored s1rollno = 20; s1marks = 900; printf( %d,s1rollno); The above code will show erroneous output The value of rollno is lost as most recently we have stored value in marks This is because all the members share same memory space 4 All the members can be initialized while declaring the variable of structure Only first member can be initialized while declaring the variable of union In above example we can initialize only variable rollno at the time of declaration of variable // CSE/CE/IT 124 JULY 2015, 8b - Find the occurrences of given character in a file
9 FILE *fp; char ch,c; int cnt=0; fp=fopen("saitxt","r"); if(fp==null) printf("unable to open\n"); exit(0); printf("enter any character\n"); scanf(" %c",&ch); while((c=fgetc(fp))!=eof) if(ch==c) cnt++; printf("occurrences of \'%c\' character in a file=%d\n",ch,cnt); 9a nested structure with example in class notes 9bclass notes
int Return the number of characters in string s.
1a.String handling functions: Function strcmp(const char *s1, const char *s2) strcpy(char *s1, const char *s2) strlen(const char *) strcat(char *s1, Data type returned int Task Compare two strings lexicographically.
More informationUnit III Functions. C functions can be classified into two categories, namely, library functions and user defined functions.
Unit III Functions Functions: Function Definition, Function prototype, types of User Defined Functions, Function calling mechanisms, Built-in string handling and character handling functions, recursion,
More informationUnit IV & V Previous Papers 1 mark Answers
1 What is pointer to structure? Pointer to structure: Unit IV & V Previous Papers 1 mark Answers The beginning address of a structure can be accessed through the use of the address (&) operator If a variable
More informationPrevious papers Program
Previous papers Program //Palindrome using recursion If the given number is a palindrome, then count the no. of digits in that given number and find the prime digits in that given number. int palin(int,int);
More information'C' Programming Language
F.Y. Diploma : Sem. II [DE/EJ/ET/EN/EX] 'C' Programming Language Time: 3 Hrs.] Prelim Question Paper Solution [Marks : 70 Q.1 Attempt any FIVE of the following : [10] Q.1(a) Define pointer. Write syntax
More informationExample: Structure, Union. Syntax. of Structure: struct book { char title[100]; char author[50] ]; float price; }; void main( )
Computer Programming and Utilization ( CPU) 110003 Structure, Union 1 What is structure? How to declare a Structure? Explain with Example Structure is a collection of logically related data items of different
More informationStructure, Union. Ashishprajapati29.wordpress.com. 1 What is structure? How to declare a Structure? Explain with Example
Structure, Union 1 What is structure? How to declare a Structure? Explain with Example Structure s a collection of logically related data items of different data types grouped together under a single name.
More informationUnit 1 - Arrays. 1 What is an array? Explain with Example. What are the advantages of using an array?
1 What is an array? Explain with Example. What are the advantages of using an array? An array is a fixed-size sequenced collection of elements of the same data type. An array is derived data type. The
More informationDarshan Institute of Engineering & Technology for Diploma Studies Unit 5
1 What is structure? How to declare a Structure? Explain with Example Structure is a collection of logically related data items of different data types grouped together under a single name. Structure is
More informationCS11001/CS11002 Programming and Data Structures (PDS) (Theory: 3-1-0) Introduction to arrays
CS11001/CS11002 Programming and Data Structures (PDS) (Theory: 3-1-0) Introduction to arrays 1 What are Arrays? Arrays are our first example of structured data. Think of a book with pages numbered 1,2,...,400.
More informationIV Unit Second Part STRUCTURES
STRUCTURES IV Unit Second Part Structure is a very useful derived data type supported in c that allows grouping one or more variables of different data types with a single name. The general syntax of structure
More information2.2 Pointers. Department of CSE
2.2 Pointers 1 Department of CSE Objectives To understand the need and application of pointers To learn how to declare a pointer and how it is represented in memory To learn the relation between arrays
More informationUNIT-V. Structures. The general syntax of structure is given below: Struct <tagname> { datatype membername1; datatype membername2; };
UNIT-V Structures Structure is a very useful derived data type supported in c that allows grouping one or more variables of different data types with a single name. The general syntax of structure is given
More informationF.Y. Diploma : Sem. II [CO/CD/CM/CW/IF] Programming in C
F.Y. Diploma : Sem. II [CO/CD/CM/CW/IF] Programming in C Time : 3 Hrs.] Prelim Question Paper Solution [Marks : 70 Q.1 Attempt any FIVE of the following : [10] Q.1 (a) List any four relational operators.
More informationSaini Technologies ADVANCED C PROGRAMMING WITH SAINI TECHNOLOGIES. Sushil Kumar Saini Mo.
Saini Technologies ADVANCED C PROGRAMMING WITH SAINI TECHNOLOGIES Sushil Kumar Saini Email: Sushilsaini04@gmail.com Mo. 9896470047 Integer Array int a[]=12,34,54,45,34,34; printf("%d",a[0]); printf(" %d",a[1]);
More information/* Area and circumference of a circle */ /*celsius to fahrenheit*/
/* Area and circumference of a circle */ #include #include #define pi 3.14 int radius; float area, circum; printf("\nenter radius of the circle : "); scanf("%d",&radius); area = pi
More informationScheme G. Sample Test Paper-I. Course Name : Computer Engineering Group Course Code : CO/CD/CM/CW/IF Semester : Second Subject Tile : Programming in C
Sample Test Paper-I Marks : 25 Time:1 Hrs. Q1. Attempt any THREE 09 Marks a) State four relational operators with meaning. b) State the use of break statement. c) What is constant? Give any two examples.
More informationM3-R4: PROGRAMMING AND PROBLEM SOLVING THROUGH C LANGUAGE
M3-R4: PROGRAMMING AND PROBLEM SOLVING THROUGH C LANGUAGE NOTE: 1. There are TWO PARTS in this Module/Paper. PART ONE contains FOUR questions and PART TWO contains FIVE questions. 2. PART ONE is to be
More informationSri vidya college of engineering and technology UNIT II FUNCTIONS, POINTERS, STRUCTURES AND UNIONS
UNIT II FUNCTIONS, POINTERS, STRUCTURES AND UNIONS FUNCTIONS AND POINTERS Functions are created when the same process or an algorithm to be repeated several times in various places in the program. Function
More informationUNIT III ARRAYS AND STRINGS
UNIT III ARRAYS AND STRINGS Arrays Initialization Declaration One dimensional and Two dimensional arrays. String- String operations String Arrays. Simple programs- sorting- searching matrix operations.
More informationPESIT Bangalore South Campus Hosur road, 1km before ElectronicCity, Bengaluru -100 Department of Basic Science and Humanities
INTERNAL ASSESSMENT TEST-3 Date : 12-05-2016 Marks: 40 Subject & Code : Programming in C and data structures (15PCD23) Sec : F,G,H,I,J,K Name of faculty :Dr J Surya Prasad/Mr.Sreenath M V/Ms.Monika/ Time
More informationScheme of valuations-test 3 PART 1
Scheme of valuations-test 3 PART 1 1 a What is string? Explain with example how to pass string to a function. Ans A string constant is a one-dimensional array of characters terminated by a null ( \0 )
More informationArrays. Arrays are of 3 types One dimensional array Two dimensional array Multidimensional array
Arrays Array is a collection of similar data types sharing same name or Array is a collection of related data items. Array is a derived data type. Char, float, int etc are fundamental data types used in
More informationMAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION (Autonomous) (ISO/IEC Certified)
Subject Code: 17212 Model Answer Page No: 1/28 Important Instructions to examiners: 1) The answers should be examined by key words and not as word-to-word as given in themodel answer scheme. 2) The model
More informationPESIT Bangalore South Campus Hosur road, 1km before Electronic City, Bengaluru -100 Department of Basic Science and Humanities
PESIT Bangalore South Campus Hosur road, 1km before Electronic City, Bengaluru -100 Department of Basic Science and Humanities Continuous Internal Evaluation Test 2 Date: 0-10- 2017 Marks: 0 Subject &
More informationSubject: Fundamental of Computer Programming 2068
Subject: Fundamental of Computer Programming 2068 1 Write an algorithm and flowchart to determine whether a given integer is odd or even and explain it. Algorithm Step 1: Start Step 2: Read a Step 3: Find
More informationUNIT-IV. Structure is a user-defined data type in C language which allows us to combine data of different types together.
UNIT-IV Unit 4 Command Argument line They are parameters/arguments supplied to the program when it is invoked. They are used to control program from outside instead of hard coding those values inside the
More informationAn array is a collection of similar elements that is all the elements in an array should have same data type. This means that an array can store
An array is a collection of similar elements that is all the elements in an array should have same data type. This means that an array can store either all integers, all floating point numbers, all characters,
More informationModule 6: Array in C
1 Table of Content 1. Introduction 2. Basics of array 3. Types of Array 4. Declaring Arrays 5. Initializing an array 6. Processing an array 7. Summary Learning objectives 1. To understand the concept of
More informationMAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
Important Instructions to examiners: 1) The answers should be examined by key words and not as word-to-word as given in the model answer scheme. 2) The model answer and the answer written by candidate
More informationProgramming in C Lab
Programming in C Lab 1a. Write a program to find biggest number among given 3 numbers. ALGORITHM Step 1 : Start Start 2 : Input a, b, c Start 3 : if a > b goto step 4, otherwise goto step 5 Start 4 : if
More informationQ 1. Attempt any TEN of the following:
Subject Code: 17212 Model Answer Page No: 1 / 26 Important Instructions to examiners: 1) The answers should be examined by key words and not as word-to-word as given in the model answer scheme. 2) The
More informationBangalore South Campus
USN: 1 P E PESIT Bangalore South Campus Hosur road, 1km before ElectronicCity, Bengaluru -100 Department of Basic Science and Humanities INTERNAL ASSESSMENT TEST 3 Date: 22/11/2017 Time:11:30am- 1.00 pm
More informationF.E. Sem. II. Structured Programming Approach
F.E. Sem. II Structured Programming Approach Time : 3 Hrs.] Mumbai University Examination Paper Solution - May 14 [Marks : 80 Q.1(a) What do you mean by algorithm? Which points you should consider [4]
More informationIntroduction to C Language (M3-R )
Introduction to C Language (M3-R4-01-18) 1. Each question below gives a multiple choice of answers. Choose the most appropriate one and enter in OMR answer sheet supplied with the question paper, following
More informationUNIT - V STRUCTURES AND UNIONS
UNIT - V STRUCTURES AND UNIONS STRUCTURE DEFINITION A structure definition creates a format that may be used to declare structure variables. Let us use an example to illustrate the process of structure
More informationFunctions. Arash Rafiey. September 26, 2017
September 26, 2017 are the basic building blocks of a C program. are the basic building blocks of a C program. A function can be defined as a set of instructions to perform a specific task. are the basic
More informationA. Year / Module Semester Subject Topic 2016 / V 2 PCD Pointers, Preprocessors, DS
Syllabus: Pointers and Preprocessors: Pointers and address, pointers and functions (call by reference) arguments, pointers and arrays, address arithmetic, character pointer and functions, pointers to pointer,initialization
More informationSubject: PROBLEM SOLVING THROUGH C Time: 3 Hours Max. Marks: 100
Code: DC-05 Subject: PROBLEM SOLVING THROUGH C Time: 3 Hours Max. Marks: 100 NOTE: There are 11 Questions in all. Question 1 is compulsory and carries 16 marks. Answer to Q. 1. must be written in the space
More informationWrite a C program using arrays and structure
03 Arrays and Structutes 3.1 Arrays Declaration and initialization of one dimensional, two dimensional and character arrays, accessing array elements. (10M) 3.2 Declaration and initialization of string
More informationAMCAT Automata Coding Sample Questions And Answers
1) Find the syntax error in the below code without modifying the logic. #include int main() float x = 1.1; switch (x) case 1: printf( Choice is 1 ); default: printf( Invalid choice ); return
More informationArray. Arijit Mondal. Dept. of Computer Science & Engineering Indian Institute of Technology Patna IIT Patna 1
IIT Patna 1 Array Arijit Mondal Dept. of Computer Science & Engineering Indian Institute of Technology Patna arijit@iitp.ac.in Array IIT Patna 2 Many applications require multiple data items that have
More informationComputer Programming. C Array is a collection of data belongings to the same data type. data_type array_name[array_size];
Arrays An array is a collection of two or more adjacent memory cells, called array elements. Array is derived data type that is used to represent collection of data items. C Array is a collection of data
More informationME 172. C Programming Language Sessional Lecture 8
ME 172 C Programming Language Sessional Lecture 8 Functions Functions are passages of code that have been given a name. C functions can be classified into two categories Library functions User-defined
More informationSRI VIDYA COLLEGE OF ENGINEERING & TECHNOLOGY, VIRUDHUNAGAR Department of CSE & IT Internal Test I
SRI VIDYA COLLEGE OF ENGINEERING & TECHNOLOGY, VIRUDHUNAGAR Department of CSE & IT Internal Test I Year & Sem: I B.E (CSE) & II Date of Exam: 21/02/2015 Subject Code & Name: CS6202 & Programming & Data
More informationMAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION (Autonomous) (ISO/IEC Certified) MODEL ANSWER
Important Instructions to examiners: 1) The answers should be examined by key words and not as word-to-word as given in the model answer scheme. 2) The model answer and the answer written by candidate
More informationVariables Data types Variable I/O. C introduction. Variables. Variables 1 / 14
C introduction Variables Variables 1 / 14 Contents Variables Data types Variable I/O Variables 2 / 14 Usage Declaration: t y p e i d e n t i f i e r ; Assignment: i d e n t i f i e r = v a l u e ; Definition
More information***************OUTPUT*************************** Enter the two number The addition of two number is =100
/* 1. Program to calculate the addition of two number using function */ int n1,n2,result; printf(" Enter the two number \n"); scanf("%d%d",&n1,&n2); result=addnum(n1,n2); printf(" The addition of two number
More informationMODULE V: POINTERS & PREPROCESSORS
MODULE V: POINTERS & PREPROCESSORS INTRODUCTION As you know, every variable is a memory-location and every memory-location has its address defined which can be accessed using ampersand(&) operator, which
More informationMidterm Examination # 2 Wednesday, March 19, Duration of examination: 75 minutes STUDENT NAME: STUDENT ID NUMBER:
Page 1 of 7 School of Computer Science 60-141-01 Introduction to Algorithms and Programming Winter 2014 Midterm Examination # 2 Wednesday, March 19, 2014 ANSWERS Duration of examination: 75 minutes STUDENT
More informationDeveloped By: P.Venkateshwarlu, Alphores Womens Degree College, Karimnagar
B.Sc (Computer Science) 1 sem Practical Solutions 1.Program to find biggest in 3 numbers using conditional operators. # include # include int a, b, c, big ; printf("enter three numbers
More information1. Basics 1. Write a program to add any two-given integer. Algorithm Code 2. Write a program to calculate the volume of a given sphere Formula Code
1. Basics 1. Write a program to add any two-given integer. Algorithm - 1. Start 2. Prompt user for two integer values 3. Accept the two values a & b 4. Calculate c = a + b 5. Display c 6. Stop int a, b,
More informationDecision Making -Branching. Class Incharge: S. Sasirekha
Decision Making -Branching Class Incharge: S. Sasirekha Branching The C language programs presented until now follows a sequential form of execution of statements. Many times it is required to alter the
More informationC Program. Output. Hi everyone. #include <stdio.h> main () { printf ( Hi everyone\n ); }
C Program Output #include main () { printf ( Hi everyone\n ); Hi everyone #include main () { printf ( Hi everyone\n ); #include and main are Keywords (or Reserved Words) Reserved Words
More information#include <stdio.h> int main() { char s[] = Hsjodi, *p; for (p = s + 5; p >= s; p--) --*p; puts(s); return 0;
1. Short answer questions: (a) Compare the typical contents of a module s header file to the contents of a module s implementation file. Which of these files defines the interface between a module and
More informationstruct structure_name { //Statements };
Introduction to Structure http://www.studytonight.com/c/structures-in-c.php Structure is a user-defined data type in C which allows you to combine different data types to store a particular type of record.
More informationTwo Dimensional Array - An array with a multiple indexs.
LAB5 : Arrays Objectives: 1. To learn how to use C array as a counter. 2. To learn how to add an element to the array. 3. To learn how to delete an element from the array. 4. To learn how to declare two
More informationPROGRAMMING IN C LAB MANUAL FOR DIPLOMA IN ECE/EEE
PROGRAMMING IN C LAB MANUAL FOR DIPLOMA IN ECE/EEE 1. Write a C program to perform addition, subtraction, multiplication and division of two numbers. # include # include int a, b,sum,
More informationUnit 3 Functions. 1 What is user defined function? Explain with example. Define the syntax of function in C.
1 What is user defined function? Explain with example. Define the syntax of function in C. A function is a block of code that performs a specific task. The functions which are created by programmer are
More informationPERIYAR CENTENARY POLYTECHNIC COLLEGE Periyar Nagar- Vallam Thanjavur
PERIYAR CENTENARY POLYTECHNIC COLLEGE Periyar Nagar- Vallam-613 403 Thanjavur 01. Define program? 02. What is program development cycle? 03. What is a programming language? 04. Define algorithm? 05. What
More informationP.E.S. INSTITUTE OF TECHNOLOGY BANGALORE SOUTH CAMPUS 1 ST INTERNAL ASSESMENT TEST (SCEME AND SOLUTIONS)
FACULTY: Ms. Saritha P.E.S. INSTITUTE OF TECHNOLOGY BANGALORE SOUTH CAMPUS 1 ST INTERNAL ASSESMENT TEST (SCEME AND SOLUTIONS) SUBJECT / CODE: Programming in C and Data Structures- 15PCD13 What is token?
More informationFor Solved Question Papers of UGC-NET/GATE/SET/PGCET in Computer Science, visit
For Solved Question Papers of UGC-NET/GATE/SET/PGCET in Computer Science, visit http://victory4sure.weebly.com/ For Solved Question Papers of UGC-NET/GATE/SET/PGCET in Computer Science, visit http://victory4sure.weebly.com/
More informationWhat we have learned so far
What we have learned so far Straight forward statements Conditional statements (branching) Repeated statements (loop) Arrays One variable many data Problem: Read 10 numbers from the keyboard and store
More informationPointers. Introduction
Pointers Spring Semester 2007 Programming and Data Structure 1 Introduction A pointer is a variable that represents the location (rather than the value) of a data item. They have a number of useful applications.
More informationChapter 2. Introduction to C language. Together Towards A Green Environment
Chapter 2 Introduction to C language Aim Aim of this chapter is to provide the fundamentals for basic program construction using C. Objectives To understand the basic information such as keywords, character
More informationOutline Introduction Arrays Declaring Arrays Examples Using Arrays Passing Arrays to Functions Sorting Arrays
Arrays Outline 1 Introduction 2 Arrays 3 Declaring Arrays 4 Examples Using Arrays 5 Passing Arrays to Functions 6 Sorting Arrays 7 Case Study: Computing Mean, Median and Mode Using Arrays 8 Searching Arrays
More informationCS11001/CS11002 Programming and Data Structures (PDS) (Theory: 3-0-0)
CS11001/CS11002 Programming and Data Structures (PDS) (Theory: 3-0-0) Class Teacher: Pralay Mitra Department of Computer Science and Engineering Indian Institute of Technology Kharagpur An Example: Random
More information1) Write a C Program to check whether given year is Leap year or not. AIM: A C Program to check whether given year is Leap year or not.
1) Write a C Program to check whether given year is Leap year or not. AIM: A C Program to check whether given year is Leap year or not. #include int year; printf("enter a year:"); scanf("%d",&year);
More informationGovernment Polytechnic Muzaffarpur.
Government Polytechnic Muzaffarpur. Name of the Lab: COMPUTER PROGRAMMING LAB (MECH. ENGG. GROUP) Subject Code: 1625408 Experiment: 1 Aim: Programming exercise on executing a C program. If you are looking
More informationPrinciples of C and Memory Management
COMP281 Lecture 9 Principles of C and Memory Management Dr Lei Shi Last Lecture Today Pointer to Array Pointer Arithmetic Pointer with Functions struct Storage classes typedef union String struct struct
More informationSUMMER 13 EXAMINATION Model Answer
Important Instructions to examiners: 1) The answers should be examined by key words and not as word-to-word as given in the model answer scheme. 2) The model answer and the answer written by candidate
More informationTest Paper 3 Programming Language Solution Question 1: Briefly describe the structure of a C program. A C program consists of (i) functions and (ii) statements There should be at least one function called
More informationAryan College. Fundamental of C Programming. Unit I: Q1. What will be the value of the following expression? (2017) A + 9
Fundamental of C Programming Unit I: Q1. What will be the value of the following expression? (2017) A + 9 Q2. Write down the C statement to calculate percentage where three subjects English, hindi, maths
More informationA3-R3: PROGRAMMING AND PROBLEM SOLVING THROUGH 'C' LANGUAGE
A3-R3: PROGRAMMING AND PROBLEM SOLVING THROUGH 'C' LANGUAGE NOTE: 1. There are TWO PARTS in this Module/Paper. PART ONE contains FOUR questions and PART TWO contains FIVE questions. 2. PART ONE is to be
More informationUNIVERSITY OF WINDSOR Fall 2007 QUIZ # 2 Solution. Examiner : Ritu Chaturvedi Dated :November 27th, Student Name: Student Number:
UNIVERSITY OF WINDSOR 60-106-01 Fall 2007 QUIZ # 2 Solution Examiner : Ritu Chaturvedi Dated :November 27th, 2007. Student Name: Student Number: INSTRUCTIONS (Please Read Carefully) No calculators allowed.
More informationCOP 3223 Introduction to Programming with C - Study Union - Fall 2017
COP 3223 Introduction to Programming with C - Study Union - Fall 2017 Chris Marsh and Matthew Villegas Contents 1 Code Tracing 2 2 Pass by Value Functions 4 3 Statically Allocated Arrays 5 3.1 One Dimensional.................................
More informationStructures Unions and Enumerated Datatypes 224
STRUCTURES, UNIONS AND ENUMERATED DATA TYPES LEARNING OBJECTIVES After reading this chapter, the readers will be able to understand the purpose of the user defined data types Structures, Unions and Enumerated
More informationStructured programming
Exercises 6 Version 1.0, 25 October, 2016 Table of Contents 1. Arrays []................................................................... 1 1.1. Declaring arrays.........................................................
More information"'"' .;, b) F or ( c = l ; c <= 10,"' c++ ) X { JJ. ~. Computer Programming I COME Midterm Examination. Fall November 2016
Group B ~. Computer Programming I COME 103 - Midterm Examination B Fall 2016 21 November 2016 1. Identify and correct the errors in each of the following statements. (Note: There may be more than one error.)
More informationSingle Dimension Arrays
ARRAYS Single Dimension Arrays Array Notion of an array Homogeneous collection of variables of same type. Group of consecutive memory locations. Linear and indexed data structure. To refer to an element,
More informationINDIAN INSTITUTE OF TECHNOLOGY KHARAGPUR Stamp / Signature of the Invigilator
INDIAN INSTITUTE OF TECHNOLOGY KHARAGPUR Stamp / Signature of the Invigilator EXAMINATION ( Mid Semester ) SEMESTER ( Autumn ) Roll Number Section Name Subject Number C S Subject Name Programming and Data
More informationFirst of all, it is a variable, just like other variables you studied
Pointers: Basics What is a pointer? First of all, it is a variable, just like other variables you studied So it has type, storage etc. Difference: it can only store the address (rather than the value)
More informationArrays. Dr. Madhumita Sengupta. Assistant Professor IIIT Kalyani
Arrays Dr. Madhumita Sengupta Assistant Professor IIIT Kalyani INTRODUCTION An array is a collection of similar data s / data types. The s of the array are stored in consecutive memory locations and are
More informationPointers. Mr. Ovass Shafi (Assistant Professor) Department of Computer Applications
Pointers Introduction: A variable is a named memory location that holds some value. Each variable has some address associated with it. Till now we only worked on the values stored in the variables and
More informationMODULE 1. Introduction to Data Structures
MODULE 1 Introduction to Data Structures Data Structure is a way of collecting and organizing data in such a way that we can perform operations on these data in an effective way. Data Structures is about
More informationMemory. What is memory? How is memory organized? Storage for variables, data, code etc. Text (Code) Data (Constants) BSS (Global and static variables)
Memory Allocation Memory What is memory? Storage for variables, data, code etc. How is memory organized? Text (Code) Data (Constants) BSS (Global and static variables) Text Data BSS Heap Stack (Local variables)
More informationArray Initialization
Array Initialization Array declarations can specify initializations for the elements of the array: int primes[10] = { 2, 3, 5, 7, 11, 13, 17, 19, 23, 29 ; initializes primes[0] to 2, primes[1] to 3, primes[2]
More informationPreprocessing directives are lines in your program that start with `#'. The `#' is followed by an identifier that is the directive name.
Unit-III Preprocessor: The C preprocessor is a macro processor that is used automatically by the C compiler to transform your program before actual compilation. It is called a macro processor because it
More informationAdvantages of writing algorithm
Advantages of writing algorithm Effective communication: Algorithm is written using English like language,algorithm is better way of communicating the logic to the concerned people Effective Analysis:
More informationC PROGRAMMING Lecture 4. 1st semester
C PROGRAMMING Lecture 4 1st semester 2017-2018 Structures Structure: Collection of one or more variables a tool for grouping heterogeneous elements together (different types) Array: a tool for grouping
More informationQuestions Bank. 14) State any four advantages of using flow-chart
Questions Bank Sub:PIC(22228) Course Code:-EJ-2I ----------------------------------------------------------------------------------------------- Chapter:-1 (Overview of C Programming)(10 Marks) 1) State
More informationUNIT 6. STRUCTURED DATA TYPES PART 1: ARRAYS
UNIT 6. STRUCTURED DATA TYPES PART 1: ARRAYS Programming Year 2017-2018 Industrial Technology Engineering Paula de Toledo Contents 1. Structured data types vs simple data types 2. Arrays (vectors and matrices)
More informationC Exercises. Ben Vandiver February 28, 2003
C Exercises Ben Vandiver February 28, 2003 1 General Information These exercises are intended for you to practice on. Since they won t be graded, they are to help you practice the types of things you will
More informationMidterm Examination # 2 Wednesday, March 18, Duration of examination: 75 minutes STUDENT NAME: STUDENT ID NUMBER:
Page 1 of 8 School of Computer Science 60-141-01 Introduction to Algorithms and Programming Winter 2015 Midterm Examination # 2 Wednesday, March 18, 2015 ANSWERS Duration of examination: 75 minutes STUDENT
More information4(a) ADDITION OF TWO NUMBERS. Program:
4(a) ADDITION OF TWO NUMBERS int a,b,c: printf( enter the elements a and b ); scanf( %d%d,&a,&b); c=a+b; printf( sum of the elements is%d,c); Output: Enter the elements a and b: 4 5 Sum of the elements
More informationCOP 3223 Introduction to Programming with C - Study Union - Fall 2017
COP 3223 Introduction to Programming with C - Study Union - Fall 2017 Chris Marsh and Matthew Villegas Contents 1 Code Tracing 2 2 Pass by Value Functions 4 3 Statically Allocated Arrays 5 3.1 One Dimensional.................................
More informationLectures 5-6: Introduction to C
Lectures 5-6: Introduction to C Motivation: C is both a high and a low-level language Very useful for systems programming Faster than Java This intro assumes knowledge of Java Focus is on differences Most
More informationAlgorithms Lab (NCS 551)
DRONACHARYA GROUP OF INSTITUTIONS, GREATER NOIDA Affiliated to Utter Pradesh Technical University Noida Approved by AICTE Algorithms Lab (NCS 551) SOLUTIONS 1. PROGRAM TO IMPLEMENT INSERTION SORT. #include
More informationArrays in C. Prof. Indranil Sen Gupta Dept. of Computer Science & Engg. Indian Institute of Technology Kharagpur. Basic Concept
Arrays in C Prof. Indranil Sen Gupta Dept. of Computer Science & Engg. Indian Institute of Technology Kharagpur 1 Basic Concept Many applications require multiple data items that have common characteristics.
More informationEx. No. 3 C PROGRAMMING
Ex. No. 3 C PROGRAMMING C is a powerful, portable and elegantly structured programming language. It combines features of a high-level language with the elements of an assembler and therefore, suitable
More information