Department of Computer Applications

Size: px
Start display at page:

Download "Department of Computer Applications"

Transcription

1 Sheikh Ul Alam Memorial Degree College Mr. Ovass Shafi. (Assistant Professor) C Language An Overview (History of C) C programming languages is the only programming language which falls under the category of mid level programming language. Popularly known as mother of all languages, C is a general purpose programming languages and can be used to develop System as well as Application Programs. It was originally developed by Dennis M. Ritche in 1970s at the Bell Labs in California. The idea behind the development of C Language was to rewrite much of the Unix Operating system in some machine independent language in order to port UNIX on to other architecturally dissimilar machines. UNIX was originally written for a DEC PDP-7 computer by Ken Thompson, an electrical engineer and a colleague of Ritchie s at Bells Labs. Thompson had written the first UNIX in a language he used to call B. To rewrite the UNIX using assembly language was out of question, as it was not portable. There arises a need for a language that would permit assembly like operations such as bit manipulation along with the feature of portability. None of the languages then available could have served the purpose. Therefore a new language was developed and hence come into existence C Language. Variable A variable is a named memory location used to store data. The value of the variable may change during the execution of program. To solve real world problems, we often store some data and then retrieve it later for further processing. In order to achieve this goal variables are used. Data Type In C programming language each variable has a specific data type. The data type specifies the number of things to the compiler. It is the data type that specifies what kind of data a variable is going to store, the number of bytes that will be allocated for a

2 variable, type of operations allowed on that variable, range of values that can assigned to a variable and finally the format specifier for the variable used to display the value of a variable. Datatypes available in C Data Types Integer Types Floating Point / Real Types int char float double Range Modifiers/ Qualifiers Range Modifiers / Qualifiers long long double unsigned signed short long unsigned signed unsigned int signed int short int long int unsigned char signed char

3 Sheikh Ul Alam Memorial Degree College Variables of Type int Mr. Ovass Shafi. (Assistant Professor) signed int / int In C programming language, before using any variable it must be declared explicitly along with its data type. The syntax for the declaration of variable in C programming is as Data type identifier; In order to define the variable of type int, the declaration statement will look like int num1; int var1, var2, result; The first statement declares an integer variable num1, the second statement declares three integer variables namely var1, var2 and result. If we omit the range modifier/qualifier, then the default modifier is always signed. Therefore the above statements and the given below statements are equal signed int num1; signed int var1, var2, result; We can store the signed integer values (values without fraction) in these variables, i.e. these variables may be either positive or negative integers within the range set for the variables of type int. The range of values that can be assigned to any variable is very much machine dependent. For most compilers for the IBM PC ints are stored in two consecutive bytes and are restricted to the range of to However on modern machines ints can be of 4 bytes. We can also define and declare the variable in the single statement like int num1=20;

4 Sheikh Ul Alam Memorial Degree College signed int var1=10,var2=20,result=var1+var2; Mr. Ovass Shafi. (Assistant Professor) In above statements the variables are declared and defined in single statement and is known as initialization of variable. If we declare a variable but don t assign any value to it, it will not be automatically initialized to zero (0) but will store some unknown value known as garbage value in C terminology. If we want to print the value of variable num1 declared above, we can do it using the printf () function, however if we write the output statement as printf( Value of num1 =num1 ); The above statement will display Value of num1 = num1. But we want to display result as Value of num1 = 20 To display the value of the variable we have to use specific format specifier for the variable and the format specifier for int/signed int is %d. To display value of num1 on screen the output statement will be like printf( Value of num1 =%d,num1); Finally the operations that are allowed to be performed on the variables of type int/signed int are addition, subtraction, multiplication, division and modulus (remainder). The program given below will help to understand most of the concepts about signed int type: /*Prog2a.c*/ #include<stdio.h> #include<conio.h> void main()

5 { signed int num1, num2,result; clrscr(); num1=10; num2=3; result=num1+num2; printf("\nsum of %d and %d is %d",num1,num2,result); result=num1-num2; printf("\ndifference of %d and %d is %d",num1,num2,result); result=num1*num2; printf("\nproduct of %d and %d is %d",num1,num2,result); result=num1/num2; printf("\nquotient from %d Divided by %d is \ %d",num1,num2,result); result=num1%num2; printf("\nremainder from %d Divided by %d is \ %d",num1,num2,result); getch(); } The output of above program is: unsigned int Usually in signed integer numbers one bit is always reserved for storing the sign of the number. For positive numbers the sign bit is always 0 and for negative numbers the sign bit is always 1. However if a variable is declared as unsigned int, no sign bit is used and all the bits are used to represent the magnitude of the number. That is why unsigned int

6 can only hold positive integral values. In unsigned int we have one more bit available to store the number and thus the range of values that can be assigned to variables of these types is from 0 to We use unsigned integer variables when we deal with data that is non negative. The most common use of unsigned int is to represent memory addresses. Just as %d is used to print signed int values, %u is the format specifier for unsigned int variables. If we want to print the value of unsigned int variable, we have to use %u instead of %d. The following programs will help to clearly understand the use of unsigned int data type. Usage: Unsigned int identifier; short int / signed short int The short int declaration may be useful in cases where an integer variable is known beforehand to be small. The variable declared as short int ensures that the range of the variable will not exceed that of signed ints. Usually short modifier is obsolete on most of the modern computers and compilers however on some computers the range may be shorter and may accommodate one byte of memory only and can assume values from to The format specifier for signed short int is also same as that of int (%d) and the same operations as that of int can be performed on variables of type short int. unsigned short int The unsigned short int declaration may be useful in cases where an integer variable is known beforehand to be small and non negative. The variable declared as unsigned short int ensures that the range of the variable will not exceed that of unsigned ints. Usually unsigned short modifier is obsolete on most of the modern computers and compilers however on some computers the range may be shorter and may accommodate one byte of memory only and can assume values from 0 to The format specifier for signed

7 short int also same as that of unsigned int (%u) and the same operations as that of unsigned int can be performed on variables of type unsigned short int. signed long int/long int Syntax: signed long int population; Or long int population; The signed long int variables are required when we use integers larger than the range that is available for int. On most computers long ints are 4 bytes wide and can store the values in the range to They support the same operations that are supported by integer variables. When we assign the value to long int variable the value on right side is immediately followed by l Or L. population= l; The format specifier for the long int is %ld. unsigned long int Syntax: unsigned long int population; Usually in signed long integer numbers one bit is always reserved for storing the sign of the number. For positive numbers the sign bit is always 0 and for negative numbers the sign bit is always 1. However if a variable is declared as unsigned long int, no sign bit is used and all the bits are used to represent the magnitude of the number. That is why unsigned long int can only hold positive integral values. In unsigned long int we have one more bit available to store the number and thus the range of values that can be assigned to variables of these types is from 0 to We use unsigned long integer variables when we deal with data that is non negative. Just as %ld is used to print signed long int values, %lu is the format specifier for unsigned long int variables. If we want to print the value of unsigned long int variable, we have to use %lu instead of %ld.

8 In the above declarations we can use short form of declarations also as shown: Complete declaration signed int x; Short hand declaration int x unsigned int y; unsigned y; signed long int p; long p; unsigned long int q; unsigned long q; singed short int r; short r; unsigned short int s; unsigned short s; Variables of Type char Sometimes the user is interested in storing character values instead of numeric values. To store character values we can declare variable of type char. Character variable is a named memory location that can hold a single character from the ASCII set. The character variable occupies the least memory for storing data. A single ASCII character can be accommodated in single byte of memory. To assign a character to character variable, the character literal need to be enclosed in single quote. The syntax for declaring and defining character variable is shown below: char var1= a ; char var2; var2= x ; Actually, character data is stored in the form of integers. Each character is assigned an ASCII code. The ASCII code for a is 97 and that of b is 98. The ASCII code for z is 122. For A, the ASCII code is 65 and that of B is 66. The ASCII code for Z is 90. The digits also have ASCII codes; 48 for 0, 49 for 1, 50 for 2 and soon. The ASCII code for 9 is 57.

9 Therefore in var1 declared above, the value stored in var1 will be Therefore character variable are actually the subset of integers. In order to display the character value of a variable, we can use %c as format specifier, however we can also display ASCII/Decimal Code of any character variable using %d specifier. The range of values that can be assigned to signed char variable is -128 to +127 and that of unsigned char variable is 0 to We can perform all the operations on character variables that can be performed on ints. Besides we can assign integer values to character variables also. For example if we want to assign A to character variable var1 it can be done in any of the following ways: char var1= A ; char var1=65; The above two statements will do the same task. Variables of Type float The integer and character variables are used to store decimal and character values. We can store only numeric data without fractional parts in the integer and character variables. However in some applications it is necessary to work on numerals with fractional parts. C provides the facility to the programmers to work with numerals with fractional parts called floats. The numbers with fractional parts are called floats because the user can change the position of the decimal point as per the precision required. The floating point numbers has two parts namely mantissa and exponent. The mantissa part can be fractional and may consist of integer part and fractional part. However the exponent is always integer value and represents the position of the decimal point within the mantissa. The floating point numbers are always signed i.e. the left most bit is always used as sign bit. There is no unsigned floating point concept as in characters and integers. When we assign value to floating point number, the value must be followed immediately by f; the syntax for usage of floating point number is shown below:

10 Sheikh Ul Alam Memorial Degree College float x= f; Mr. Ovass Shafi. (Assistant Professor) float y= e04f; float z=232.02e-01f; Variables of Type double The float data type allows us to store values with fractional values and also to perform calculations with fractional values but the limitation of float data type is that it provides single precision arithmetic. But there are situations where large scale scientific or engineering calculations are involved, and thus the double precision floating point computations are required. The facility is available with double data type in C programming language. The variable of type double occupies 8 consecutive bytes in memory and provides capability to produce computational results correct to 14 significant digits. The range of values that can be assigned to variable of type double lies between 1.7E-308 and 1.7E+308. The operations that can be performed on variable of type double are same as that of float variables. The format specifiers used to display the value of double variables are %lf, %le, %lg, however most common format specifier used is %le. All the three format specifiers are counterparts of their single precision (float). Any numeral with decimal point is treated as double even if it lies within the range of float. So in order to treat a number with decimal point as float, it must be followed immediately by f or F. long double Syntax: long double PI; The long double variables are required when we use fractional values larger than the range that is available for double. On most computers long doubles are 10 bytes wide and can store the values in the range 3.4E-4932 to 3.4E They support the same operations that are supported by float variables.

11 The format specifier for the long double is %Lf, %Le, %Lg. Most commonly used format specifier is %Le. Identifiers & Keywords An identifier is any user defined word in C program used for naming variables, programs, arrays, functions, structures, enumerations, unions etc. Names of identifiers should be chosen as such that they represent their roles within the program for example to add two numbers, the better variable names would be num1, num2 and sum, instead of x, y, and z. Rules for creating identifiers. The identifier names are sequences of character chosen from the set [A Z, a z, 0-9,_], of which the first character must not be a digit. No two variables must have same names as it would create name conflicts and hence programming errors. Identifiers can be of any suitable length. Generally 8 10 characters should suffice, though certain compilers may allow for very much longer names of upto 63 characters. Two identifiers will be considered different if they differ upto their first 31 characters. The identifier should not be same to that of some keyword. C is a case sensitive language, so num1, Num1 and num1 will be considered three different variable names. Some of the valid identifiers are: Num_1, num1, _hello, hello, HELLO Some of the invalid identifiers are: 1_num, while, 123, num-1, num.1, num 1

12 Keywords Keywords are the predefined words in any programming language which can t be used in any context other than that predefined in the language. A list of keywords available in C is listed below: auto break case char const continue default do double else enum extern float for goto if int long register return short signed sizeof static struct switch typedef union unsigned void volatile while Expressions & Operators One of the most powerful features of C programming language is the versatility of its operators. There are number of operators available in C for arithmetic computation, relational operators for making comparisons, increment and decrement operators, cast operators, assignment operators, logical operators, bitwise operators, conditional operators and many more. We will look on some of the operators in this unit, and the rest will be covered in subsequent chapters. First of all we will define the term operator and operand. An Operator is a symbol that specifies the type of operation that is to be performed like +, -, *,<, > etc. When we use operator, we have to provide the data on which the operation is to be performed. The data on which the specific operation is performed is known as Operand. An operand can be a variable, constant or a literal. Some operators operate on single operand and are known as Unary Operators for example -3, x++ etc. Some operators operate on two operands and

13 are known as Binary Operators like 2+3, 4*6, 4<6 etc. Some operators operate on three operands and are known as Ternary Operators. There is only one tertiary operator available in C language and is called conditional operator (?:) which we will see later in this chapter. when we want to perform some computation, we combine the operators and operands. The valid combination of operators and operands forms Expression which is evaluated to get the desired results. Basic Arithmetic Operators and Operations. There are four basic arithmetic operators available in C. These are for addition (+), subtraction (-), multiplication (*) and division (/). Besides we can use modulus operator (%) to calculate the remainder by dividing dividend with a divisor. Among these operators, addition and subtraction operator can act as unary as well as binary operators while as rest three operators can be used as binary operators only. If we want to multiply the two numbers and assign the result to the third variable, we will have to use three operands (multiplier, multiplicand and destination variable) and two operators as shown: x=y*z In the above statement there are two operators. One is multiplication operator (*) and the second one is assignment operator (=). The assignment operator assigns the quantity on its right to the variable on its left. So the assignment operator s associativity is from right to left in contrast to basic arithmetic operators that associates from left to right, as most of the C operators do. Consider the statement given below: i=i+1 One should not be confused from the above expression. In programming i=i+1 should not be read as i is equal to i+1 (LHS = RHS). As i can t be equal to i+1. In programming i=i+1 means replace the previous contents of i by adding 1 to the previous contents of i. Each operator has two properties associated with it. The precedence and associativity. When there is more than one operator occurring in an expression, it is the relative

14 priorities of the operators with respect to each other that will determine the order in which the expression will be evaluated. The associativity defines the direction left-toright or right-to-left, in which the operator acts upon its operands. The second property priority is also important consideration during the evaluation of expressions. The priority of all the C operators along with their associativity is given in table below: Table Precedence and Associativity of Operators Operators (priority is increasing from top to down Associativity. () [] ->. Left to Right! ~ * & (type cast) sizeof (all unary operators) Right to Left */ % Left to Right + - Left to Right << >> Left to Right < <= > >= Left to Right ==!= Left to Right & Left to Right ^ Left to Right Left to Right && Left to Right Left to Right? : Left to Right = += -= *= /= %= &= ^= = <<= >>= Right to Left, Left to Right

15 The operators at the top of the table parenthesis (), array operator [], arrow operator - > and the dot. operators are known a primary operators. All theses operators have same priority among themselves but higher than that of all other operators. After than the unary operators have higher priority than binary operators which in turn has higher priority than ternary operators. If a user is not sure about the priority of the operators, then he can make use of parenthesis to override the normal priority of the operators for example consider the expression x=3*4+2 as per normal rules multiplication has higher priority than addition. So the result of above expression will be 3*4=12 and then =14. Therefore x will be assigned the value of 14. Now consider the same expression but with parenthesis. X=3*(4+2) The presence of parenthesis around the addition operator gives higher priority to addition operator than multiplication. Therefore the result of above expression will be 4+2=6 and then 3*6 =18. Therefore x will be assigned the value of 18. Increment and Decrement operators Most often in programming we need to update the value of the variable by some amount. To increase the value of variable is known as increment and is done by additive operator (+). Similarly sometimes we need to update the value of the variable by decreasing it and is known as decrement. For example x=x+1; /*increment value of x by 1*/ y=y-1; /*decrement value of y by 1*/

16 There are number of ways to increment and decrement the value of a variable and are shown below: x=x+1; x=x+5; x+=1; x+=3; x++; ++x; x=x-1; x-=1; x=x-5; x-=5; x--; --x; /*increment value of x by 1 using normal arithmetic operator*/ /*increment value of x by 5 using normal arithmetic operator*/ /*increment value of x by 1 using arithmetic assignment operator*/ /*increment value of x by 3 using arithmetic assignment operator*/ /*increment value of x by 1 using post increment operator*/ /*increment value of x by 1 using pre increment operator*/ /*decrement value of x by 1 using normal arithmetic operator*/ /*decrement value of x by 1 using arithmetic assignment operator*/ /*decrement value of x by 5 using normal arithmetic operator*/ /*decrement value of x by 1 using arithmetic assignment operator*/ /* decrement value of x by 1 using post decrement operator*/ /* decrement value of x by 1 using pre decrement operator*/ If the post and pre increment/decrement is used on single variable without embedding in expression then both have the same effect, i.e. increase the value of variable by 1. However when they are used with expressions then they act differently. The Pre increment/decrement operator updates the value of their target variables before the execution of expressions. Once the variable is updated the expression is then evaluated using the new values. With Post increment/decrement operators the expression is evaluated using previous values of variables and after the result of evaluated expression is used, the variables are updated. The effect of increment will not be reflected in the result.

17 Sheikh Ul Alam Memorial Degree College For example if x=2, and y=3 Mr. Ovass Shafi. (Assistant Professor) z=x++ + y++; After expression evaluation, values will be x=3, y=4 and z=5. As the variables x and y are operated on by post increment, the expression will be evaluated using the original values of x and y i.e. 2 and 3 respectively. So z will get the value 2+3 = 5. After evaluation of expression value of x and y will be incremented by 1. Now consider the same expression but using pre increment using same values x=2 and y=3 z=++x + ++y; In above expression, the value of x and y will be incremented by 1 before the evaluation of expression and after the value of x and y becomes 3 and 4, the expression will be evaluated and z will have the value 3+4=7. getch(), getche(), getchar() functions (Single Character Input) We can read character using getch (), getche () and getchar () functions also. To print character data, we can use putchar () function. The following program illustrates the use of printf (), scanf (), getchar (), getch (), getche () and putchar () functions. /*Prog2l.c*/ #include<stdio.h> #include<conio.h> void main() { int a,b,c; float x,y,z; char ch; clrscr(); printf("\nenter any two integer values:->"); scanf("%d%d",&a,&b);

18 c=a+b; printf("\nsum of %d and %d is %d",a,b,c); printf("\nenter any two Floating Point values:->"); scanf("%f",&x); scanf("%f",&y); z=x+y; printf("\nsum of %.2f and %.2f is %.2f",x,y,z); printf("\nhit any key on keyboard:->"); fflush(stdin); scanf("%c",&ch); printf("\nyou Hit %c",ch); printf("\nhit any key on keyboard:->"); ch=getch(); printf("\nyou Hit %c",ch); printf("\nhit any key on keyboard:->"); ch=getche(); printf("\nyou Hit %c",ch); printf("\nhit any key on keyboard:->"); fflush(stdin); ch=getchar(); printf("you Hit "); putchar(ch); getch(); } Formatted Input/Output In C language the output is generated using printf () function. The printf () function can be used to output character strings as well as number. So far we have used printf () function to simply print the output without any proper format, however the printf ()

19 function can be used to deliver the formatted output of numbers of variables and expressions of any type. As specified earlier, the printf () function used two arguments. The first one is control string, and second is the list of variables. If we specify the control string and list of variables, the output will be generated in unformatted manner. However if we want output to be formatted, the control string is provided with Format specifications. The Format specifications controls how the variables or expressions should be displayed on the screen. To illustrate the unformatted output consider the following program segment. /*Prog3g.c*/ #include<stdio.h> #include<conio.h> void main() { long int p1,p2,p3; clrscr(); printf("\ncountry\tpopulation:->"); p1= ; p2=12323; p3= ; printf("\nindia\%d",p1); printf("\nafghanistan\%d",p2); printf("\namerica\%d",p3); getch(); } As seen from the output, the output is jumbled and not in proper format. It is hard to read and understand. Now the same program can be rewritten using formatted output as below:

20 /*Prog3h.c*/ #include<stdio.h> #include<conio.h> void main() { long int p1,p2,p3; clrscr(); printf("\n%20s%20s","country","population"); p1= ; p2=12323; p3= ; printf("\n%20s%20d","india",p1); printf("\n%20s%20d","afghanistan",p2); printf("\n%20s%20d","america",p3); getch(); } gets() and puts() functions: For reading strings at runtime we can use either scanf() or gets() function. using scanf (), we have to use %s as format specifier but scanf() function can read single word string. When user inputs space character, the scanf() function terminates input process. Another function that can be used to input strings is gets() function. This function accepts one argument, i.e. string to be read. This function can read multiple word string and terminates input when enter key is pressed, i.e. when newline is inserted. We can also use puts(string) for printing the string on screen. The string input/output didn t require loops for printing individual character of string as in integer, float, double, and character arrays. The reason for this is that the format specifier starts printing elements of string from the base address till it encounters null character. In other types of arrays there is no

21 null character and hence we need to run loop from 0 to the last element to process all the elements of array. The following program illustrates the process of string input: /*Prog8f.c String Input at Runtime*/ #include<stdio.h> #include<conio.h> void main() { char str1[100]; char *str2; /*dynamic string*/ clrscr(); printf("\nenter Any Single Word String\n"); scanf("%s",str1); printf("\nenter Any Multiple Word String\n"); fflush(stdin); gets(str2); printf("\nstring I is %s",str1); printf("\nstring II is %s",str2); puts(str1); puts(str2); getch(); }

Programming and Data Structures

Programming and Data Structures Programming and Data Structures Teacher: Sudeshna Sarkar sudeshna@cse.iitkgp.ernet.in Department of Computer Science and Engineering Indian Institute of Technology Kharagpur #include int main()

More information

UNIT - I. Introduction to C Programming. BY A. Vijay Bharath

UNIT - I. Introduction to C Programming. BY A. Vijay Bharath UNIT - I Introduction to C Programming Introduction to C C was originally developed in the year 1970s by Dennis Ritchie at Bell Laboratories, Inc. C is a general-purpose programming language. It has been

More information

Features of C. Portable Procedural / Modular Structured Language Statically typed Middle level language

Features of C. Portable Procedural / Modular Structured Language Statically typed Middle level language 1 History C is a general-purpose, high-level language that was originally developed by Dennis M. Ritchie to develop the UNIX operating system at Bell Labs. C was originally first implemented on the DEC

More information

DEPARTMENT OF MATHS, MJ COLLEGE

DEPARTMENT OF MATHS, MJ COLLEGE T. Y. B.Sc. Mathematics MTH- 356 (A) : Programming in C Unit 1 : Basic Concepts Syllabus : Introduction, Character set, C token, Keywords, Constants, Variables, Data types, Symbolic constants, Over flow,

More information

Computers Programming Course 5. Iulian Năstac

Computers Programming Course 5. Iulian Năstac Computers Programming Course 5 Iulian Năstac Recap from previous course Classification of the programming languages High level (Ada, Pascal, Fortran, etc.) programming languages with strong abstraction

More information

ANSI C Programming Simple Programs

ANSI C Programming Simple Programs ANSI C Programming Simple Programs /* This program computes the distance between two points */ #include #include #include main() { /* Declare and initialize variables */ double

More information

These are reserved words of the C language. For example int, float, if, else, for, while etc.

These are reserved words of the C language. For example int, float, if, else, for, while etc. Tokens in C Keywords These are reserved words of the C language. For example int, float, if, else, for, while etc. Identifiers An Identifier is a sequence of letters and digits, but must start with a letter.

More information

Computer System and programming in C

Computer System and programming in C 1 Basic Data Types Integral Types Integers are stored in various sizes. They can be signed or unsigned. Example Suppose an integer is represented by a byte (8 bits). Leftmost bit is sign bit. If the sign

More information

UNIT- 3 Introduction to C++

UNIT- 3 Introduction to C++ UNIT- 3 Introduction to C++ C++ Character Sets: Letters A-Z, a-z Digits 0-9 Special Symbols Space + - * / ^ \ ( ) [ ] =!= . $, ; : %! &? _ # = @ White Spaces Blank spaces, horizontal tab, carriage

More information

C Programming Multiple. Choice

C Programming Multiple. Choice C Programming Multiple Choice Questions 1.) Developer of C language is. a.) Dennis Richie c.) Bill Gates b.) Ken Thompson d.) Peter Norton 2.) C language developed in. a.) 1970 c.) 1976 b.) 1972 d.) 1980

More information

Programming Fundamentals (CS 302 ) Dr. Ihsan Ullah. Lecturer Department of Computer Science & IT University of Balochistan

Programming Fundamentals (CS 302 ) Dr. Ihsan Ullah. Lecturer Department of Computer Science & IT University of Balochistan Programming Fundamentals (CS 302 ) Dr. Ihsan Ullah Lecturer Department of Computer Science & IT University of Balochistan 1 Outline p Introduction p Program development p C language and beginning with

More information

Basics of Programming

Basics of Programming Unit 2 Basics of Programming Problem Analysis When we are going to develop any solution to the problem, we must fully understand the nature of the problem and what we want the program to do. Without the

More information

Guide for The C Programming Language Chapter 1. Q1. Explain the structure of a C program Answer: Structure of the C program is shown below:

Guide for The C Programming Language Chapter 1. Q1. Explain the structure of a C program Answer: Structure of the C program is shown below: Q1. Explain the structure of a C program Structure of the C program is shown below: Preprocessor Directives Global Declarations Int main (void) Local Declarations Statements Other functions as required

More information

UNIT IV 2 MARKS. ( Word to PDF Converter - Unregistered ) FUNDAMENTALS OF COMPUTING & COMPUTER PROGRAMMING

UNIT IV 2 MARKS. ( Word to PDF Converter - Unregistered )   FUNDAMENTALS OF COMPUTING & COMPUTER PROGRAMMING ( Word to PDF Converter - Unregistered ) http://www.word-to-pdf-converter.net FUNDAMENTALS OF COMPUTING & COMPUTER PROGRAMMING INTRODUCTION TO C UNIT IV Overview of C Constants, Variables and Data Types

More information

Pointers. Mr. Ovass Shafi (Assistant Professor) Department of Computer Applications

Pointers. 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 information

C - Basic Introduction

C - Basic Introduction C - Basic Introduction C is a general-purpose high level language that was originally developed by Dennis Ritchie for the UNIX operating system. It was first implemented on the Digital Equipment Corporation

More information

LESSON 1. A C program is constructed as a sequence of characters. Among the characters that can be used in a program are:

LESSON 1. A C program is constructed as a sequence of characters. Among the characters that can be used in a program are: LESSON 1 FUNDAMENTALS OF C The purpose of this lesson is to explain the fundamental elements of the C programming language. C like other languages has all alphabet and rules for putting together words

More information

Preview from Notesale.co.uk Page 6 of 52

Preview from Notesale.co.uk Page 6 of 52 Binary System: The information, which it is stored or manipulated by the computer memory it will be done in binary mode. RAM: This is also called as real memory, physical memory or simply memory. In order

More information

Programming in C and Data Structures [15PCD13/23] 1. PROGRAMMING IN C AND DATA STRUCTURES [As per Choice Based Credit System (CBCS) scheme]

Programming in C and Data Structures [15PCD13/23] 1. PROGRAMMING IN C AND DATA STRUCTURES [As per Choice Based Credit System (CBCS) scheme] Programming in C and Data Structures [15PCD13/23] 1 PROGRAMMING IN C AND DATA STRUCTURES [As per Choice Based Credit System (CBCS) scheme] Course objectives: The objectives of this course is to make students

More information

UNIT 3 OPERATORS. [Marks- 12]

UNIT 3 OPERATORS. [Marks- 12] 1 UNIT 3 OPERATORS [Marks- 12] SYLLABUS 2 INTRODUCTION C supports a rich set of operators such as +, -, *,,

More information

PESIT 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 INTERNAL ASSESSMENT TEST 1 SOLUTION PART 1 1 a Define algorithm. Write an algorithm to find sum and average of three numbers. 4 An Algorithm is a step by step procedure to solve a given problem in finite

More information

IECD Institute for Entrepreneurship and Career Development Bharathidasan University, Tiruchirappalli 23.

IECD Institute for Entrepreneurship and Career Development Bharathidasan University, Tiruchirappalli 23. Subject code - CCP01 Chapt Chapter 1 INTRODUCTION TO C 1. A group of software developed for certain purpose are referred as ---- a. Program b. Variable c. Software d. Data 2. Software is classified into

More information

C: How to Program. Week /Mar/05

C: How to Program. Week /Mar/05 1 C: How to Program Week 2 2007/Mar/05 Chapter 2 - Introduction to C Programming 2 Outline 2.1 Introduction 2.2 A Simple C Program: Printing a Line of Text 2.3 Another Simple C Program: Adding Two Integers

More information

PART I. Part II Answer to all the questions 1. What is meant by a token? Name the token available in C++.

PART I.   Part II Answer to all the questions 1. What is meant by a token? Name the token available in C++. Unit - III CHAPTER - 9 INTRODUCTION TO C++ Choose the correct answer. PART I 1. Who developed C++? (a) Charles Babbage (b) Bjarne Stroustrup (c) Bill Gates (d) Sundar Pichai 2. What was the original name

More information

A Fast Review of C Essentials Part I

A Fast Review of C Essentials Part I A Fast Review of C Essentials Part I Structural Programming by Z. Cihan TAYSI Outline Program development C Essentials Functions Variables & constants Names Formatting Comments Preprocessor Data types

More information

Fundamental of Programming (C)

Fundamental of Programming (C) Borrowed from lecturer notes by Omid Jafarinezhad Fundamental of Programming (C) Lecturer: Vahid Khodabakhshi Lecture 3 Constants, Variables, Data Types, And Operations Department of Computer Engineering

More information

Work relative to other classes

Work relative to other classes Work relative to other classes 1 Hours/week on projects 2 C BOOTCAMP DAY 1 CS3600, Northeastern University Slides adapted from Anandha Gopalan s CS132 course at Univ. of Pittsburgh Overview C: A language

More information

I Internal Examination Sept Class: - BCA I Subject: - Principles of Programming Lang. (BCA 104) MM: 40 Set: A Time: 1 ½ Hrs.

I Internal Examination Sept Class: - BCA I Subject: - Principles of Programming Lang. (BCA 104) MM: 40 Set: A Time: 1 ½ Hrs. I Internal Examination Sept. 2018 Class: - BCA I Subject: - Principles of Programming Lang. (BCA 104) MM: 40 Set: A Time: 1 ½ Hrs. [I]Very short answer questions (Max 40 words). (5 * 2 = 10) 1. What is

More information

Variables Data types Variable I/O. C introduction. Variables. Variables 1 / 14

Variables 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

A flow chart is a graphical or symbolic representation of a process.

A flow chart is a graphical or symbolic representation of a process. Q1. Define Algorithm with example? Answer:- A sequential solution of any program that written in human language, called algorithm. Algorithm is first step of the solution process, after the analysis of

More information

Fundamentals of Programming

Fundamentals of Programming Fundamentals of Programming Lecture 3 - Constants, Variables, Data Types, And Operations Lecturer : Ebrahim Jahandar Borrowed from lecturer notes by Omid Jafarinezhad Outline C Program Data types Variables

More information

Chapter 2 - Introduction to C Programming

Chapter 2 - Introduction to C Programming Chapter 2 - Introduction to C Programming 2 Outline 2.1 Introduction 2.2 A Simple C Program: Printing a Line of Text 2.3 Another Simple C Program: Adding Two Integers 2.4 Memory Concepts 2.5 Arithmetic

More information

Presented By : Gaurav Juneja

Presented By : Gaurav Juneja Presented By : Gaurav Juneja Introduction C is a general purpose language which is very closely associated with UNIX for which it was developed in Bell Laboratories. Most of the programs of UNIX are written

More information

Character Set. The character set of C represents alphabet, digit or any symbol used to represent information. Digits 0, 1, 2, 3, 9

Character Set. The character set of C represents alphabet, digit or any symbol used to represent information. Digits 0, 1, 2, 3, 9 Character Set The character set of C represents alphabet, digit or any symbol used to represent information. Types Uppercase Alphabets Lowercase Alphabets Character Set A, B, C, Y, Z a, b, c, y, z Digits

More information

Lecture 02 C FUNDAMENTALS

Lecture 02 C FUNDAMENTALS Lecture 02 C FUNDAMENTALS 1 Keywords C Fundamentals auto double int struct break else long switch case enum register typedef char extern return union const float short unsigned continue for signed void

More information

C Language Part 1 Digital Computer Concept and Practice Copyright 2012 by Jaejin Lee

C Language Part 1 Digital Computer Concept and Practice Copyright 2012 by Jaejin Lee C Language Part 1 (Minor modifications by the instructor) References C for Python Programmers, by Carl Burch, 2011. http://www.toves.org/books/cpy/ The C Programming Language. 2nd ed., Kernighan, Brian,

More information

The component base of C language. Nguyễn Dũng Faculty of IT Hue College of Science

The component base of C language. Nguyễn Dũng Faculty of IT Hue College of Science The component base of C language Nguyễn Dũng Faculty of IT Hue College of Science Content A brief history of C Standard of C Characteristics of C The C compilation model Character set and keyword Data

More information

UNIT IV INTRODUCTION TO C

UNIT IV INTRODUCTION TO C UNIT IV INTRODUCTION TO C 1. OVERVIEW OF C C is portable, structured programming language. It is robust, fast.extensible. It is used for complex programs. The root of all modern language is ALGOL (1960).

More information

CSc 10200! Introduction to Computing. Lecture 2-3 Edgardo Molina Fall 2013 City College of New York

CSc 10200! Introduction to Computing. Lecture 2-3 Edgardo Molina Fall 2013 City College of New York CSc 10200! Introduction to Computing Lecture 2-3 Edgardo Molina Fall 2013 City College of New York 1 C++ for Engineers and Scientists Third Edition Chapter 2 Problem Solving Using C++ 2 Objectives In this

More information

Data Types and Variables in C language

Data Types and Variables in C language Data Types and Variables in C language Basic structure of C programming To write a C program, we first create functions and then put them together. A C program may contain one or more sections. They are

More information

Chapter 1 & 2 Introduction to C Language

Chapter 1 & 2 Introduction to C Language 1 Chapter 1 & 2 Introduction to C Language Copyright 2007 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Chapter 1 & 2 - Introduction to C Language 2 Outline 1.1 The History

More information

Fundamental of C programming. - Ompal Singh

Fundamental of C programming. - Ompal Singh Fundamental of C programming - Ompal Singh HISTORY OF C LANGUAGE IN 1960 ALGOL BY INTERNATIONAL COMMITTEE. IT WAS TOO GENERAL AND ABSTRUCT. IN 1963 CPL(COMBINED PROGRAMMING LANGUAGE) WAS DEVELOPED AT CAMBRIDGE

More information

C OVERVIEW BASIC C PROGRAM STRUCTURE. C Overview. Basic C Program Structure

C OVERVIEW BASIC C PROGRAM STRUCTURE. C Overview. Basic C Program Structure C Overview Basic C Program Structure C OVERVIEW BASIC C PROGRAM STRUCTURE Goals The function main( )is found in every C program and is where every C program begins speed execution portability C uses braces

More information

CS113: Lecture 3. Topics: Variables. Data types. Arithmetic and Bitwise Operators. Order of Evaluation

CS113: Lecture 3. Topics: Variables. Data types. Arithmetic and Bitwise Operators. Order of Evaluation CS113: Lecture 3 Topics: Variables Data types Arithmetic and Bitwise Operators Order of Evaluation 1 Variables Names of variables: Composed of letters, digits, and the underscore ( ) character. (NO spaces;

More information

VARIABLES AND CONSTANTS

VARIABLES AND CONSTANTS UNIT 3 Structure VARIABLES AND CONSTANTS Variables and Constants 3.0 Introduction 3.1 Objectives 3.2 Character Set 3.3 Identifiers and Keywords 3.3.1 Rules for Forming Identifiers 3.3.2 Keywords 3.4 Data

More information

C OVERVIEW. C Overview. Goals speed portability allow access to features of the architecture speed

C OVERVIEW. C Overview. Goals speed portability allow access to features of the architecture speed C Overview C OVERVIEW Goals speed portability allow access to features of the architecture speed C fast executables allows high-level structure without losing access to machine features many popular languages

More information

Chapter 7. Basic Types

Chapter 7. Basic Types Chapter 7 Basic Types Dr. D. J. Jackson Lecture 7-1 Basic Types C s basic (built-in) types: Integer types, including long integers, short integers, and unsigned integers Floating types (float, double,

More information

Expressions and Data Types CSC 121 Spring 2015 Howard Rosenthal

Expressions and Data Types CSC 121 Spring 2015 Howard Rosenthal Expressions and Data Types CSC 121 Spring 2015 Howard Rosenthal Lesson Goals Understand the basic constructs of a Java Program Understand how to use basic identifiers Understand simple Java data types

More information

Model Viva Questions for Programming in C lab

Model Viva Questions for Programming in C lab Model Viva Questions for Programming in C lab Title of the Practical: Assignment to prepare general algorithms and flow chart. Q1: What is a flowchart? A1: A flowchart is a diagram that shows a continuous

More information

Introduction to C Programming. Chih-Wei Tang ( 唐之瑋 ) Department of Communication Engineering National Central University JhongLi, Taiwan

Introduction to C Programming. Chih-Wei Tang ( 唐之瑋 ) Department of Communication Engineering National Central University JhongLi, Taiwan Introduction to C Programming Chih-Wei Tang ( 唐之瑋 ) Department of Communication Engineering National Central University JhongLi, Taiwan Outline Printing texts Adding 2 integers Comparing 2 integers C.E.,

More information

Basic Elements of C. Staff Incharge: S.Sasirekha

Basic Elements of C. Staff Incharge: S.Sasirekha Basic Elements of C Staff Incharge: S.Sasirekha Basic Elements of C Character Set Identifiers & Keywords Constants Variables Data Types Declaration Expressions & Statements C Character Set Letters Uppercase

More information

I BCA[ ] SEMESTER I CORE: C PROGRAMMING - 106A Multiple Choice Questions.

I BCA[ ] SEMESTER I CORE: C PROGRAMMING - 106A Multiple Choice Questions. 1 of 22 8/4/2018, 4:03 PM Dr.G.R.Damodaran College of Science (Autonomous, affiliated to the Bharathiar University, recognized by the UGC)Reaccredited at the 'A' Grade Level by the NAAC and ISO 9001:2008

More information

Variables and Operators 2/20/01 Lecture #

Variables and Operators 2/20/01 Lecture # Variables and Operators 2/20/01 Lecture #6 16.070 Variables, their characteristics and their uses Operators, their characteristics and their uses Fesq, 2/20/01 1 16.070 Variables Variables enable you to

More information

About Codefrux While the current trends around the world are based on the internet, mobile and its applications, we try to make the most out of it. As for us, we are a well established IT professionals

More information

C Programming a Q & A Approach

C Programming a Q & A Approach C Programming a Q & A Approach by H.H. Tan, T.B. D Orazio, S.H. Or & Marian M.Y. Choy Chapter 2 Variables, Arithmetic Expressions and Input/Output 2.1 Variables: Naming, Declaring, Assigning and Printing

More information

Operators in C. Staff Incharge: S.Sasirekha

Operators in C. Staff Incharge: S.Sasirekha Operators in C Staff Incharge: S.Sasirekha Operators An operator is a symbol which helps the user to command the computer to do a certain mathematical or logical manipulations. Operators are used in C

More information

Data Types. Data Types. Integer Types. Signed Integers

Data Types. Data Types. Integer Types. Signed Integers Data Types Data Types Dr. TGI Fernando 1 2 The fundamental building blocks of any programming language. What is a data type? A data type is a set of values and a set of operations define on these values.

More information

BLM2031 Structured Programming. Zeyneb KURT

BLM2031 Structured Programming. Zeyneb KURT BLM2031 Structured Programming Zeyneb KURT 1 Contact Contact info office : D-219 e-mail zeynebkurt@gmail.com, zeyneb@ce.yildiz.edu.tr When to contact e-mail first, take an appointment What to expect help

More information

IMPORTANT QUESTIONS IN C FOR THE INTERVIEW

IMPORTANT QUESTIONS IN C FOR THE INTERVIEW IMPORTANT QUESTIONS IN C FOR THE INTERVIEW 1. What is a header file? Header file is a simple text file which contains prototypes of all in-built functions, predefined variables and symbolic constants.

More information

Expressions and Data Types CSC 121 Fall 2015 Howard Rosenthal

Expressions and Data Types CSC 121 Fall 2015 Howard Rosenthal Expressions and Data Types CSC 121 Fall 2015 Howard Rosenthal Lesson Goals Understand the basic constructs of a Java Program Understand how to use basic identifiers Understand simple Java data types and

More information

Types, Operators and Expressions

Types, Operators and Expressions Types, Operators and Expressions CSE 2031 Fall 2011 9/11/2011 5:24 PM 1 Variable Names (2.1) Combinations of letters, numbers, and underscore character ( _ ) that do not start with a number; are not a

More information

C Programming Class I

C Programming Class I C Programming Class I Generation of C Language Introduction to C 1. In 1967, Martin Richards developed a language called BCPL (Basic Combined Programming Language) 2. In 1970, Ken Thompson created a language

More information

Q 1. Attempt any TEN of the following:

Q 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 information

XSEDE Scholars Program Introduction to C Programming. John Lockman III June 7 th, 2012

XSEDE Scholars Program Introduction to C Programming. John Lockman III June 7 th, 2012 XSEDE Scholars Program Introduction to C Programming John Lockman III June 7 th, 2012 Homework 1 Problem 1 Find the error in the following code #include int main(){ } printf(find the error!\n");

More information

Computers Programming Course 6. Iulian Năstac

Computers Programming Course 6. Iulian Năstac Computers Programming Course 6 Iulian Năstac Recap from previous course Data types four basic arithmetic type specifiers: char int float double void optional specifiers: signed, unsigned short long 2 Recap

More information

Programming. Elementary Concepts

Programming. Elementary Concepts Programming Elementary Concepts Summary } C Language Basic Concepts } Comments, Preprocessor, Main } Key Definitions } Datatypes } Variables } Constants } Operators } Conditional expressions } Type conversions

More information

DECLARATIONS. Character Set, Keywords, Identifiers, Constants, Variables. Designed by Parul Khurana, LIECA.

DECLARATIONS. Character Set, Keywords, Identifiers, Constants, Variables. Designed by Parul Khurana, LIECA. DECLARATIONS Character Set, Keywords, Identifiers, Constants, Variables Character Set C uses the uppercase letters A to Z. C uses the lowercase letters a to z. C uses digits 0 to 9. C uses certain Special

More information

UIC. C Programming Primer. Bharathidasan University

UIC. C Programming Primer. Bharathidasan University C Programming Primer UIC C Programming Primer Bharathidasan University Contents Getting Started 02 Basic Concepts. 02 Variables, Data types and Constants...03 Control Statements and Loops 05 Expressions

More information

Unit 3. Operators. School of Science and Technology INTRODUCTION

Unit 3. Operators. School of Science and Technology INTRODUCTION INTRODUCTION Operators Unit 3 In the previous units (unit 1 and 2) you have learned about the basics of computer programming, different data types, constants, keywords and basic structure of a C program.

More information

Introduction to C programming. By Avani M. Sakhapara Asst Professor, IT Dept, KJSCE

Introduction to C programming. By Avani M. Sakhapara Asst Professor, IT Dept, KJSCE Introduction to C programming By Avani M. Sakhapara Asst Professor, IT Dept, KJSCE Classification of Software Computer Software System Software Application Software Growth of Programming Languages History

More information

Course Outline Introduction to C-Programming

Course Outline Introduction to C-Programming ECE3411 Fall 2015 Lecture 1a. Course Outline Introduction to C-Programming Marten van Dijk, Syed Kamran Haider Department of Electrical & Computer Engineering University of Connecticut Email: {vandijk,

More information

CprE 288 Introduction to Embedded Systems Exam 1 Review. 1

CprE 288 Introduction to Embedded Systems Exam 1 Review.  1 CprE 288 Introduction to Embedded Systems Exam 1 Review http://class.ece.iastate.edu/cpre288 1 Overview of Today s Lecture Announcements Exam 1 Review http://class.ece.iastate.edu/cpre288 2 Announcements

More information

Java Notes. 10th ICSE. Saravanan Ganesh

Java Notes. 10th ICSE. Saravanan Ganesh Java Notes 10th ICSE Saravanan Ganesh 13 Java Character Set Character set is a set of valid characters that a language can recognise A character represents any letter, digit or any other sign Java uses

More information

ADARSH VIDYA KENDRA NAGERCOIL COMPUTER SCIENCE. Grade: IX C++ PROGRAMMING. Department of Computer Science 1

ADARSH VIDYA KENDRA NAGERCOIL COMPUTER SCIENCE. Grade: IX C++ PROGRAMMING. Department of Computer Science 1 NAGERCOIL COMPUTER SCIENCE Grade: IX C++ PROGRAMMING 1 C++ 1. Object Oriented Programming OOP is Object Oriented Programming. It was developed to overcome the flaws of the procedural approach to programming.

More information

Introduction to C++ with content from

Introduction to C++ with content from Introduction to C++ with content from www.cplusplus.com 2 Introduction C++ widely-used general-purpose programming language procedural and object-oriented support strong support created by Bjarne Stroustrup

More information

6.096 Introduction to C++ January (IAP) 2009

6.096 Introduction to C++ January (IAP) 2009 MIT OpenCourseWare http://ocw.mit.edu 6.096 Introduction to C++ January (IAP) 2009 For information about citing these materials or our Terms of Use, visit: http://ocw.mit.edu/terms. Welcome to 6.096 Lecture

More information

C Language, Token, Keywords, Constant, variable

C Language, Token, Keywords, Constant, variable C Language, Token, Keywords, Constant, variable A language written by Brian Kernighan and Dennis Ritchie. This was to be the language that UNIX was written in to become the first "portable" language. C

More information

Declaration and Memory

Declaration and Memory Declaration and Memory With the declaration int width; the compiler will set aside a 4-byte (32-bit) block of memory (see right) The compiler has a symbol table, which will have an entry such as Identifier

More information

Programming in C++ 5. Integral data types

Programming in C++ 5. Integral data types Programming in C++ 5. Integral data types! Introduction! Type int! Integer multiplication & division! Increment & decrement operators! Associativity & precedence of operators! Some common operators! Long

More information

M4.1-R3: PROGRAMMING AND PROBLEM SOLVING THROUGH C LANGUAGE

M4.1-R3: PROGRAMMING AND PROBLEM SOLVING THROUGH C LANGUAGE M4.1-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 information

Types, Operators and Expressions

Types, Operators and Expressions Types, Operators and Expressions EECS 2031 18 September 2017 1 Variable Names (2.1) l Combinations of letters, numbers, and underscore character ( _ ) that do not start with a number; are not a keyword.

More information

SEQUENTIAL STRUCTURE. Erkut ERDEM Hacettepe University October 2010

SEQUENTIAL STRUCTURE. Erkut ERDEM Hacettepe University October 2010 SEQUENTIAL STRUCTURE Erkut ERDEM Hacettepe University October 2010 History of C C Developed by by Denis M. Ritchie at AT&T Bell Labs from two previous programming languages, BCPL and B Used to develop

More information

Fundamental Data Types. CSE 130: Introduction to Programming in C Stony Brook University

Fundamental Data Types. CSE 130: Introduction to Programming in C Stony Brook University Fundamental Data Types CSE 130: Introduction to Programming in C Stony Brook University Program Organization in C The C System C consists of several parts: The C language The preprocessor The compiler

More information

4.1. Structured program development Overview of C language

4.1. Structured program development Overview of C language 4.1. Structured program development 4.2. Data types 4.3. Operators 4.4. Expressions 4.5. Control flow 4.6. Arrays and Pointers 4.7. Functions 4.8. Input output statements 4.9. storage classes. UNIT IV

More information

Main Program. C Programming Notes. #include <stdio.h> main() { printf( Hello ); } Comments: /* comment */ //comment. Dr. Karne Towson University

Main Program. C Programming Notes. #include <stdio.h> main() { printf( Hello ); } Comments: /* comment */ //comment. Dr. Karne Towson University C Programming Notes Dr. Karne Towson University Reference for C http://www.cplusplus.com/reference/ Main Program #include main() printf( Hello ); Comments: /* comment */ //comment 1 Data Types

More information

Review of the C Programming Language for Principles of Operating Systems

Review of the C Programming Language for Principles of Operating Systems Review of the C Programming Language for Principles of Operating Systems Prof. James L. Frankel Harvard University Version of 7:26 PM 4-Sep-2018 Copyright 2018, 2016, 2015 James L. Frankel. All rights

More information

Subject: PROBLEM SOLVING THROUGH C Time: 3 Hours Max. Marks: 100

Subject: 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 information

P.E.S. INSTITUTE OF TECHNOLOGY BANGALORE SOUTH CAMPUS 1 ST INTERNAL ASSESMENT TEST (SCEME AND SOLUTIONS)

P.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 information

BASIC ELEMENTS OF A COMPUTER PROGRAM

BASIC ELEMENTS OF A COMPUTER PROGRAM BASIC ELEMENTS OF A COMPUTER PROGRAM CSC128 FUNDAMENTALS OF COMPUTER PROBLEM SOLVING LOGO Contents 1 Identifier 2 3 Rules for naming and declaring data variables Basic data types 4 Arithmetic operators

More information

Lecture 3. More About C

Lecture 3. More About C Copyright 1996 David R. Hanson Computer Science 126, Fall 1996 3-1 Lecture 3. More About C Programming languages have their lingo Programming language Types are categories of values int, float, char Constants

More information

Q1. Multiple Choice Questions

Q1. Multiple Choice Questions Rayat Shikshan Sanstha s S. M. Joshi College, Hadapsar Pune-28 F.Y.B.C.A(Science) Basic C Programing QUESTION BANK Q1. Multiple Choice Questions 1. Diagramatic or symbolic representation of an algorithm

More information

CS313D: ADVANCED PROGRAMMING LANGUAGE

CS313D: ADVANCED PROGRAMMING LANGUAGE CS313D: ADVANCED PROGRAMMING LANGUAGE Computer Science department Lecture 2 : C# Language Basics Lecture Contents 2 The C# language First program Variables and constants Input/output Expressions and casting

More information

2/29/2016. Definition: Computer Program. A simple model of the computer. Example: Computer Program. Data types, variables, constants

2/29/2016. Definition: Computer Program. A simple model of the computer. Example: Computer Program. Data types, variables, constants Data types, variables, constants Outline.1 Introduction. Text.3 Memory Concepts.4 Naming Convention of Variables.5 Arithmetic in C.6 Type Conversion Definition: Computer Program A Computer program is a

More information

INTRODUCTION TO C A PRE-REQUISITE

INTRODUCTION TO C A PRE-REQUISITE This document can be downloaded from www.chetanahegde.in with most recent updates. 1 INTRODUCTION TO C A PRE-REQUISITE 1.1 ALGORITHMS Computer solves a problem based on a set of instructions provided to

More information

Operators and Expressions in C & C++ Mahesh Jangid Assistant Professor Manipal University, Jaipur

Operators and Expressions in C & C++ Mahesh Jangid Assistant Professor Manipal University, Jaipur Operators and Expressions in C & C++ Mahesh Jangid Assistant Professor Manipal University, Jaipur Operators and Expressions 8/24/2012 Dept of CS&E 2 Arithmetic operators Relational operators Logical operators

More information

C-LANGUAGE CURRICULAM

C-LANGUAGE CURRICULAM C-LANGUAGE CURRICULAM Duration: 2 Months. 1. Introducing C 1.1 History of C Origin Standardization C-Based Languages 1.2 Strengths and Weaknesses Of C Strengths Weaknesses Effective Use of C 2. C Fundamentals

More information

A complex expression to evaluate we need to reduce it to a series of simple expressions. E.g * 7 =>2+ 35 => 37. E.g.

A complex expression to evaluate we need to reduce it to a series of simple expressions. E.g * 7 =>2+ 35 => 37. E.g. 1.3a Expressions Expressions An Expression is a sequence of operands and operators that reduces to a single value. An operator is a syntactical token that requires an action be taken An operand is an object

More information

Introduction to C++ Introduction. Structure of a C++ Program. Structure of a C++ Program. C++ widely-used general-purpose programming language

Introduction to C++ Introduction. Structure of a C++ Program. Structure of a C++ Program. C++ widely-used general-purpose programming language Introduction C++ widely-used general-purpose programming language procedural and object-oriented support strong support created by Bjarne Stroustrup starting in 1979 based on C Introduction to C++ also

More information

DETAILED SYLLABUS INTRODUCTION TO C LANGUAGE

DETAILED SYLLABUS INTRODUCTION TO C LANGUAGE COURSE TITLE C LANGUAGE DETAILED SYLLABUS SR.NO NAME OF CHAPTERS & DETAILS HOURS ALLOTTED 1 INTRODUCTION TO C LANGUAGE About C Language Advantages of C Language Disadvantages of C Language A Sample Program

More information

File Handling in C. EECS 2031 Fall October 27, 2014

File Handling in C. EECS 2031 Fall October 27, 2014 File Handling in C EECS 2031 Fall 2014 October 27, 2014 1 Reading from and writing to files in C l stdio.h contains several functions that allow us to read from and write to files l Their names typically

More information