FUNDAMENTALS OF COMPUTING & COMPUTER PROGRAMMING UNIT IV INTRODUCTION TO C

Size: px
Start display at page:

Download "FUNDAMENTALS OF COMPUTING & COMPUTER PROGRAMMING UNIT IV INTRODUCTION TO C"

Transcription

1 FUNDAMENTALS OF COMPUTING & COMPUTER PROGRAMMING UNIT IV INTRODUCTION TO C Overview of C Constants, Variables and Data Types Operators and Expressions Managing Input and Output operators Decision Making - Branching and Looping. 2 MARKS 1. What are the different data types available in C? There are four basic data types available in C. 1. int 2. float 3. char 4. double 2. What are Keywords? Keywords are certain reserved words that have standard and pre-defined meaning in C. These keywords can be used only for their intended purpose.

2 3. What is an Operator and Operand? An operator is a symbol that specifies an operation to be performed on operands. Example: *, +, -, / are called arithmetic operators. The data items that operators act upon are called operands. Example: a+b; In this statement a and b are called operands. 4. What is Ternary operators or Conditional operators? Ternary operators is a conditional operator with symbols? and : Syntax: variable = exp1? exp2 : exp3 If the exp1 is true variable takes value of exp2. If the exp2 is false, variable takes the value of exp3. 5. What are the Bitwise operators available in C? & - Bitwise AND - Bitwise OR ~ - One s Complement >> - Right shift << - Left shift ^ - Bitwise XOR are called bit field operators Example: k=~j; where ~ take one s complement of j and the result is stored in k.

3 6. What are the logical operators available in C? The logical operators available in C are && - Logical AND - Logical OR! - Logical NOT 7. What is the difference between Logical AND and Bitwise AND? Logical AND (&&): Only used in conjunction with two expressions, to test more than one condition. If both the conditions are true the returns 1. If false then return 0. AND (&): Only used in Bitwise manipulation. It is a unary operator. 8. What is the difference between = and == operator? Where = is an assignment operator and == is a relational operator. Example: while (i=5) is an infinite loop because it is a non zero value and while (i==5) is true only when i=5. 9. What is type casting? Type casting is the process of converting the value of an expression to a particular data type. Example:

4 int x,y; c = (float) x/y; where a and y are defined as integers. Then the result of x/y is converted into float. 10. What is conversion specification? The conversion specifications are used to accept or display the data using the INPUT/OUTPUT statements. 11. What is the difference between a and a? a is a character constant and a is a string. 12. What is the difference between if and while statement? if while (i) It is a conditional (i) It is a loop control statement statement (ii) If the condition is true, it (ii) Executes the statements within executes the some statements. (iii) If the condition is false then it stops the execution the statements. while block if the condition is true. (iii) If the condition is false the control is transferred to the next statement of the loop. 13. What is the difference between while loop and do while loop?

5 In the while loop the condition is first executed. If the condition is true then it executes the body of the loop. When the condition is false it comes of the loop. In the do while loop first the statement is executed and then the condition is checked. The do while loop will execute at least one time even though the condition is false at the very first time. 14. What is a Modulo Operator? % is modulo operator. It gives the remainder of an integer division Example: a=17, b=6. Then c=%b gives How many bytes are occupied by the int, char, float, long int and double? int - 2 Bytes char - 1 Byte float - 4 Bytes long int - 4 Bytes double - 8 Bytes 16. What are the types of I/O statements available in C? There are two types of I/O statements available in C. Formatted I/O Statements Unformatted I/O Statements 17. What is the difference between ++a and a++?

6 ++a means do the increment before the operation (pre increment) a++ means do the increment after the operation (post increment)example: a=5; x=a++; /* assign x=5*/ y=a; /*now y assigns y=6*/ x=++a; /*assigns x=7*/ 18. What is a String? String is an array of characters. 19. What is a global variable? The global variable is a variable that is declared outside of all the functions. The global variable is stored in memory, the default value is zero. Scope of this variable is available in all the functions. Life as long as the program s execution doesn t come to an end. 20. What are the Escape Sequences present in C \n - New Line \b - Backspace \t - Form feed \ - Single quote \\ - Backspace

7 \t - Tab \r - Carriage return \a - Alert \ - Double quotes 21. Construct an infinite loop using while? while (1) Here 1 is a non zero, value so the condition is always true. So it is an infinite loop. 22. What will happen when you access the array more than its dimension? When you access the array more than its dimensions some garbage value is stored in the array. 23. Write the limitations of getchar( ) and sacnf( ) functions for reading strings (JAN 2009) getchar( ) To read a single character from stdin, then getchar() is the appropriate. scanf( ) scanf( ) allows to read more than just a single character at a time.

8 24. What is the difference between scanf() and gets() function? In scanf() when there is a blank was typed, the scanf() assumes that it is an end. gets() assumes the enter key as end. That is gets() gets a new line (\n) terminated string of characters from the keyboard and replaces the \n with \ What is a Structure? Structure is a group name in which dissimilar data s are grouped together. 26. What is meant by Control String in Input/Output Statements? Control Statements contains the format code characters, specifies the type of data that the user accessed within the Input/Output statements. 27. What is Union? Union is a group name used to define dissimilar data types. The union occupies only the maximum byte of the data type. If you declare integer and character, then the union occupies only 2 bytes, whereas structure occupies only 3 bytes. 28. What is the output of the programs given below? main() main() float a; float a;

9 int x=6, y=4; int x=6, y=4; a=x\y; a=(float) x\y; printf( Value of a=%f, a); printf( Value of a=%f,a); Output: Output: Declare the Structure with an example? struct name char name[10]; int age; float salary; e1, e2; 30. Declare the Union with an example? union name char name[10]; int age;

10 float salary; e1, e2; 31. What is the output of the following program when, the name given with spaces? main() char name[50]; printf( \n name\n ); scanf( %s, name); printf( %s,name); Output: Lachi (It only accepts the data upto the spaces) 32. What is the difference between while(a) and while(!a)? while(a) means while(a!=0) while(!a) means while(a==0) 33. Why we don t use the symbol & symbol, while reading a String through scanf()? The & is not used in scanf() while reading string, because the character variable itself specifies as a base address. Example: name, &name[0] both the declarations are same.

11 34. What is the difference between static and auto storage classes? Storage Initial value Static Memory Zero Auto Memory Garbage value Scope Life Local to the block in Local to the block in which the variables is which the variable is defined defined. Value of the variable persists between different function calls. The block in which the variable is defined. 35. What is the output of the program? main() increment() increment(); static int i=1; increment(); printf( %d\n,i) increment(); i=i+1; OUTPUT: Why header files are included in C programming? This section is used to include the function definitions used in the program. Each header file has h extension and include using # include directive at the beginning of a program.

12 37. List out some of the rules used for C programming. All statements should be written in lower case letters. Upper case letters are only for symbolic constants. Blank spaces may be inserted between the words. This improves the readability of statements. It is a free-form language; we can write statements anywhere between and. a = b + c; d = b*c; (or) a = b+c; d = b*c; Opening and closing braces should be balanced. 38. Define delimiters in C. : Delimiters Colon Use Useful for label ; ( ) [ ] #, Semicolon Parenthesis Square Bracket Curly Brace Hash Comma Terminates Statement Used in expression and functions Used for array declaration Scope of statement Preprocessor directive Variable Separator

13 39. What do you mean by variables in C? A variable is a data name used for storing a data value. Can be assigned different values at different times during program execution. Can be chosen by programmer in a meaningful way so as to reflect its function in the program. Some examples are: Sum percent_1 class_total 40. List the difference between float and double datatype. S No Float Double Float / Double 1 Occupies 4 bytes in memory Occupies 8 bytes in memory 2 Range : 3.4 e-38 to Range : 1.7 e-308 to 1.7e e+38 Format Specifier: % lf 4 Format Specifier: % f Example : float a; Example : double y; There exists long double having a range of 3.4 e to 3.4 e and occupies 10 bytes in memory. Example: long double k; 41. Differentiate break and continue statement S No break continue 1 Exits from current block Loop takes next iteration / loop 2 Control passes to beginning Control passes to next of loop 3

14 statement Terminates the program Never terminates the program 42. List the types of operators. S No Operators Types Symbolic Representation 1 Arithmetic operators =, -, *, / and % Relational operators Logical operators Increment and Decrement operators Assignment operators Bitwise operators Comma operator Conditional operator >, <, ==, >=, <= and!= &&, and! ++ and =, + =, - =, * =, / =, ^ =, ; =, & = &,, ^, >>, <<, and ~,? : 43. Distinguish between while..do and do..while statement in C. (JAN 2009) While..DO (i) Executes the statements within the while block if only the condition is true. (ii) The condition is checked at the starting of the loop DO..while (i) Executes the statements within the while block at least once. (ii) The condition is checked at the end of the loop 44. Compare switch( ) and nestedif statement.

15 S No switch( ) case nested if 1 Test for equality ie., only constant It can equate relational (or) 2 values are applicable. logical expressions. 3 4 No two case statements in same switch. Character constants are automatically converted to integers. In switch( ) case statement nested if can be used. Same conditions may be repeated for a number of times. Character constants are automatically converted to integers. In nested if statement switch case can be used. 45. Distinguish Increment and Decrement operators. S No Increment ++ Decrement -- 1 Adds one to its operand Subtracts one from its operand 2 Equivalent x = x + 1 Equivalent x = x Either follow or precede operand Either follow or precede 4 operand Example : ++x; x++; Example : --x; x--; 46. Give the syntax for the for loop statement for (Initialize counter; Test condition; Increment / Decrement) statements;

16 Initialization counter sets the loop to an initial value. This statement is executed only once. The test condition is a relational expression that determines the number of iterations desired or it determines when to exit from the loop. The for loop continues to execute as long as conditional test is satisfied. When condition becomes false, the control of program exists the body of the for loop and executes next statement after the body of the loop. The increment / decrement parameter decides how to make changes in the loop. The body of the loop may contain either a single statement or multiple statements. 47. What is the use of sizeof( ) operator? The sizeof ( ) operator gives the bytes occupied by a variable. No of bytes occupied varies from variable to variable depending upon its data types. Example: int x,y; printf( %d,sizeof(x)); Output: What is a loop control statement? Many tasks done with the help of a computer are repetitive in nature. Such tasks can be done with loop control statements.

17 49. What are global variable in C? This section declares some variables that are used in more than one function. such variable are called as global variables. It should be declared outside all functions. 50. Write a program to swap the values of two variables (without temporary variable). #include <stdio.h> #include <conio.h> void main( ) int a =5; b = 10; clrscr( ); prinf( Before swapping a = %d b = %d, a, b); a = a + b; B = a b; a = a b; prinf( After swapping a = %d b = %d, a,b); getch( ); Output:

18 Before swapping a = 5 b = 10 After swapping a = 10 b = Write short notes about main ( ) function in C program. (MAY 2009) Every C program must have main ( ) function. All functions in C, has to end with ( ) parenthesis. It is a starting point of all C programs. The program execution starts from the opening brace and ends with closing brace, within which executable part of the program exists. Part B-16 marks 1. Explain in detail about C declarations and variables. 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). BCPL (Basic Combined Programming Language) a user friendly OS providing powerful development tools developed from BCPL. Assembler tedious long and error prone. A new language ``B'' a second attempt. c A totally new language ``C'' a successor to ``B''. c By 1973 UNIX OS almost totally written in ``C''.

19 Characteristics of C Some of C's characteristics that define the language and also have lead to its popularity as a programming language. Small size Supports variety of data types and a set of operators. Extensive use of function calls Enables the implementation of hierarchical and modular programming with the help of functions. C can extend itself by addition of functions to its library continuously. Structured language Low level (BitWise) programming readily available Pointer implementation - extensive use of pointers for memory, array, structures and functions. C has now become a widely used professional language for various reasons. It has high-level constructs. It can handle low-level activities. It produces efficient programs. It can be compiled on a variety of computers. Basic structure of C program

20 Documentation Section Link section Definition section Global declaration section main() function section Declaration part Executable part Sub program section Function 1 Function 2 (user defined functions) Function n 2. Explain in detail about the constants, expressions and statements in C. CONSTANTS Constants in C are applicable to values, which do not change during the execution of a program. C constants are classified as o Numeric constants Integer constants

21 Real constants o Character constants Single character constants String constants 1. Numeric constants a. Integer constants Sequence of numbers from 0 to 9 without decimal point or fractional part or any other symbols. Minimum 2 bytes, maximum 4 bytes. It may be positive or negative or zero Eg:10,+30,-15 b. Real constants floating point constants many parameters are defined in real constants like height,length,distance. Eg:2.5,3.14 It can be written in exponential notation. 2. Character constants a. Single character constant Single character Single digit or single special symbol or white space enclosed within a pair of single quote marks. Characters constants have integer values known as ASCII values. Eg: a, 8, u b. String constants Sequence of characters enclosed within double quote marks. String may be a combination of all kinds of symbols. Eg: hello, India, 444, a

22 2. Expressions: An expression represents a single data item, such as number or a character. Logical conditions that are true or false are represented by expressions. Example: a = p q / 3 + r * Statements Assignment Statements Definition and examples Null Statements Definition and examples Block of statements Definition and examples Expression statements Definition and examples Declaration statements Definition and examples 3. Discuss about the various data types in C. (MAY 2009) C support variety of data types. Data is represented using numbers or characters. C is a so called type safe programming language, that is, any variable needs to be assigned a supported data type. C supports the following data types: /* elementary data types */ bool char short int double float long signed char, int, short, unsigned char, int, short, /* customized or non-elementary data types */ struct enum Data types Size(bytes) Format specifier

23 Char 1 %c Unsigned char 1 %c Short or int 2 %i or %d Unsigned int 2 %u Long 4 %ld Unsigned long 4 %lu Float 4 %f or %g Double 8 %lf Long double 10 %lf Declaring variables Should be done in declaration part of the program. Compiler obtains the variable name. It tells the compiler the data type of the variable being declared and helps in allocating the memory. Syntax: data type variable name int age; Initializing variables Variables declared can be assigned or initialized using an assignment operator =. Syntax: Variable-name = constant Or Data-type variable name = constant

24 Eg: int y=2; int x, y,z; Example program: Addition of two numbers #include<stdio.h> #include<conio.h> void main () int a,b,c; printf( enter the values of a and b ); scanf( %d %d,&a,&b); c=a+b; printf( the value of c is=%d,c); getch(); 4. Describe the various types of operators in C language along with its priority. An operator indicates an operation to be performed on data that yields a value. 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 language program to operate on data and variables. C has a rich set of operators which can be classified as 1. Arithmetic operators +,-,*,/ and % 2. Relational Operators >,<,==,>=,<=,!= 3. Logical Operators &&,,! 4. Increments and Decrement Operators ++,-- 5. Assignment Operators = 6. Bitwise Operators &,/,>>,<<,~ 7. Comma operator,

25 8. Conditional Operators?: 1. Arithmetic Operators All the basic arithmetic operations can be carried out in C. All the operators have almost the same meaning as in other languages. Both unary and binary operations are available in C language. Unary operations operate on a singe operand, therefore the number 5 when operated by unary will have the value 5. Operator Meaning + Addition or Unary Plus Subtraction or Unary Minus * Multiplication / Division % Modulus Operator Examples of arithmetic operators are x + y x - y -x + y a * b + c -a * b here a, b, c, x, y are known as operands. The modulus operator is a special operator in C language which evaluates the remainder of the operands after division. 2. Relational Operators Often it is required to compare the relationship between operands and bring out a decision and program accordingly. This is when the relational operator comes into picture. C supports the following relational operators. Operator Meaning < is less than

26 <= is less than or equal to > is greater than >= is greater than or equal to == is equal to!= is not equal to A simple relational expression contains only one relational operator and takes the following form. exp1 relational operator exp2 Where exp1 and exp2 are expressions, which may be simple constants, variables or combination of them. Given below is a list of examples of relational expressions and evaluated values. 3. Logical Operators C has the following logical operators, they compare or evaluate logical and relational expressions. Operator Meaning && Logical AND Logical OR! Logical NOT (&&) Logical AND This operator is used to evaluate 2 conditions or expressions with relational operators simultaneously. If both the expressions to the left and to the right of the logical operator is true then the whole compound expression is true. Example a > b && x = = 10 The expression to the left is a > b and that on the right is x == 10 the whole expression is true only if both expressions are true i.e., if a is greater than b and x is equal to Increment and decrement operator: It is used to increment or decrement the value Eg:i++;

27 j--; 4. Assignment Operators The Assignment Operator evaluates an expression on the right of the expression and substitutes it to the value or variable on the left of the expression. Example x = a + b Here the value of a + b is evaluated and substituted to the variable x. In addition, C has a set of shorthand assignment operators of the form. var oper = exp; Here var is a variable, exp is an expression and oper is a C binary arithmetic operator. The operator oper = is known as shorthand assignment operator 5. Bitwise operator Operator Meaning >> right shift << left shift ^ bitwise XOR ~ one s complement & bitwise AND bitwise OR 7. Comma operator It is used to separate two or more expressions. Eg:a=2,b=4,c=a+b; 8. Conditional operator Syntax: Condition?(expression1) expression2);

28 If the condition true,the expression 1 is evaluated. If the condition is false,the expression2 is evaluated. 5.Explain about the various decision making statements in C language. (JAN 2009/FEB2010) Program is the execution of one or more instructions. Based on the condition, the order of execution may change. On the basis of applications it is essential to Alter the flow of a program. Test the logical conditions. Control the flow of execution as per the selection. C language supports the control statements as listed below. if statement if-else if-else.if switch() case 1. if statement: syntax: if(condition) statement; eg: if (a>b) printf( a is greater ); 2. if-else: Syntax: if(condition is true) execute statement1; else execute statement2; Eg: if (a>b)

29 printf( a is greater ); else printf( b is greater ); 3. Nested if-else: Rules: Nested if else can be chained with one another. If condition is false, control passes to else block. If one of the if statement satisfies the condition, other nested else if will not be executed. Syntax: if ( condition) statement1; statement2; else if( condition) Statement3; Statement4; else Statement5; Statement6; Eg: finding biggest of three numbers. #include<stdio.h>

30 #include<conio.h> main() int a,b,c,big; clrscr(); printf( Enter three numbers ); scanf( %d %d %d,&a,&b,&c); if(a>b) if(a>c) big=a; else big=c; else if(b>c) big=b; else big=c; printf( \n Biggest number is %d,big); getch(); Output: Enter three numbers: 18,-5, 13 Biggest number is 18

31 4. switch() It is multiway branch statement. It requires only one argument of any data type, which is checked with number of case options. If value matches with case constant, particular case statement is executed. If not matched, default is executed. Every case terminates with : symbol. break is used to exit from current case. Syntax: switch (variable or expression) case constant A: Statement; break; case constant B: Statement; break; default: statement; Eg: Program to find value of y #include<stdio.h> #include<conio.h> #include<math.h> main() int n;

32 float x,y; clrscr(); printf( \n Enter values to x and n: ); scanf( %f %d,&x,&n); switch(n) case 1: y=1+x; break; case 2: y=1-x; break; case 3: y=1+pow(x,n) break; default: y=1+n*x; break; printf( \n value of y(x,n)=%f),y); getch(); Output: Enter value to x and n: Value of y(x,n)=3.10

33 break statement: It allows programmers to terminate the loop. It skips from loop or block in which it is defined. continue statement: It is opposite to break. Continuing next iteration of loop statements. It does not terminate, bit it skips the statements. goto statement: It does not require any condition. It passes control anywhere in the program Syntax: goto label; Eg: even or odd using goto. #include<stdio.h> #include<conio.h> #include<stdlib.h> main() int x; clrscr(); printf( \n Enter a number: ); scanf( %d,&x); if( x%2==0) goto even;

34 else goto odd; even: printf( \n %d is even number ); return; odd: printf( \n %d is odd number ); Output: Enter a number: 5 5 is odd number. Difference between break and continue break Exits from current block or loop Control passes to nest statement Terminates the program continue Loop takes next iteration Control passes to the beginning of loop Never terminates the program 6. Write short notes on the following: (JAN 2009) for loop while loop dowhile loop Switch case (MAY 2009/FEB 2009/FEB 2010)

35 Branching and looping are used for repetitive tasks. Loop: A loop is defined as a block of statements which are repeatedly executed for certain number of times. Terms in loop are Loop variable Initialization Incrimination or decrimination Loops in C language are for() while() do while() Formats: a) for loop It allows for executing a set of instructions until a certain condition is satisfied. Syntax: for (initialize;test condition;re-evaluation parameter) Statement; Statement; for (;;) infinite loop no arguments for (a=0;a<=20;) infinite loop a is neither increased nor decreased for( a=0;a<=10;a++) displays value value of a is displayed printf( %d,a); from 0 to 10 from o to 10 for(a=10;a>=0;a--) printf( %d,a) displays from 10 to 0 value a is decreased from 10 to 0

36 Eg: display numbers from 1 to 15 using for loop #include<stdio.h> #include<conio.h> main() int i; Output: clrscr(); for( i=1;i<=15;i++) printf( %d,i);

37 Nested for loops: Using loop within loop Eg: finding perfect cubesof1,2,3,4 #include<math.h> main() int i,j,k; clrscr(); printf( Enter a number ); scanf( %d,&k); for(i=1;i<k;i++) for(j=1;j<=i;j++) if(i==pow(j,3)) printf( \n Number: %d & its cube :%d j,i); Output: Enter a number: 1000 Number:1 & its cube :1 Number:2 & its cube :8

38 Number:3 & its cube :27 Number:4 & its cube :64 b) While loop: syntax: while (test condition) Body of the loop; Loop statements will be executed till the condition is true. Test condition is evaluated and if the condition is true, body of the loop is executed. When condition becomes false the execution will be out of the loop. Eg: add 10 consecutive numbers starting from 1 main() int a=1;sum=0; clrscr(); while(a<=10) printf( %d,a); sum=sum+a; a++; printf( \n Sum of 10 numbers:%d,sum);

39 Output: Sum of 10 numbers: 55 c) do-while loop: syntax: do Statement; while (condition); condition is checked at the end of the loop. do-while loop will execute atleast one time even if the condition is false initially. do-while loop executes until the condition becomes false. Eg: main() int i=1; clrscr(); do printf( \n This is a program of do while loop ); i++; while(i<=5);

40 Output: This is a program of do while loop This is a program of do while loop This is a program of do while loop This is a program of do while loop This is a program of do while loop d) do while statement with while loop syntax: do while(condition) Statements; while(condition); Eg: Print values from 1 to 5 using while statement in do while loop main () int x=0; clrscr(); do while(x<5) x++; printf( \t %d,x); while(x<1); Output

41 7. Explain briefly about the input and output function in C. (MAY 2009/FEB 2009) Input/Output functions are classified into two types. They are, Formatted functions Unformatted function Formatted functions Read and write all types of data values. Require conversion symbol to identify the data type. Return the values after execution. Unformatted functions Only work with character data type. Do not require conversion symbol for identification of data type. Return values are always same. Input/Output Functions Formatted Functions Unformatted Functions Input Output Input Output scanf() printf() getch() Formatted Functions: 1. printf () statement: getche() getchar() gets() Prints all types of data values to the console. putch() putchar() put()

42 Requires conversion symbol and variable names to print the data. Eg: main () int x=2; float y=2.2; char z= c ; printf( %d %f %c,x,y,z); Output c 2.scanf () statement Reads all type of data values It is used for run time assignment of variables. Requires conversion symbol to identify the data to be read Syntax: scanf( %d %f%c,&a,&b,&c); &-address operator-: prints the memory location of the variable. It indicates memory location,so that the value read would be placed at that location. It also returns values. Return value is exactly equal to the number of values correctly read. If any mismatch error will shown. Eg; #include<stdio.h> #include<conio.h>

43 main() int a; clrscr(); printf( Enter the value of A ); scanf( %c,&a); printf( A=%c,a); Output: Enter the value of A =8 A=8 Escape Sequences: printf(),scanf() statements follow a combination of characters called as escape sequences.it starts with \ \ n newline \ b backspace \ f formfeed \ singlequote \\ backslash \0 NULL \ t horizontal tab

44 \ r carriage return \ a alert(bell) \ double quotes \ v vertical tab \? question mark Eg:Average of three real numbers. #include<stdio.h> #include<conio.h> main() float a,b,c,d; clrscr(); printf( Enter three float numbers:\n ); scanf( \n %f %f %f,&a,&b,&c); d=a+b+c; printf( \n Average of given numbers:%f,d/3); Output: Enter three float numbers: Average of given numbers: 3.5 Unformatted Functions: There are three types of I/O functions. 1) Character I/O

45 2) String I/O 3) File I/O 1. Character I/O a) getchar() It reads character type data from the standard input. It reads one character at a time till the user presses the enter key. b) putchar() It prints one character on the screen at a time, which is read by the standard input. c) getch() and getche() These functions read any alphanumeric characters from the standard input device. Character entered is not displayed by getch() function d) putch() It prints any alphanumericcharacter taken by the standard input device. 2.String I/O a) gets() It is used for accepting any string through stdin keyboard until enter key is pressed. stdio.h is needed for implementing the above function. b) puts() It prints the string or character array. c) cgets() It reads strings from the console.

46 Syntax: cgets(char *st); d. cputs() It displays string on the console. Syntax : cputs(char *st); 3.File I/O fprintf() - write values to files. fscanf() - read values from files. getc() - reads a single character from operand file and moves the file pointer. putc()- writea single character into a file. fgetc() - reads a character and increase the file pointer position. fputc() - writes character to file shown by the file pointer. fgets() - reads the string. fputs() - write the string to operand file. putw() - write an integer value to file. getw() - returns the integer value and increase the pointer. Commonly used library functions: a) clrscr() - clear the screen -> conio.h b) exit () - terminates the program->process.h c) sleep() -pause the execution of program for a given number of seconds-dos.h d) system () - helpful in executing different dos.

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

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

CS6202 - PROGRAMMING & DATA STRUCTURES UNIT I Part - A 1. W hat are Keywords? Keywords are certain reserved words that have standard and pre-defined meaning in C. These keywords can be used only for their

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

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

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

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

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

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

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

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

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

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

B.V. Patel Institute of Business Management, Computer & Information Technology, Uka Tarsadia University

B.V. Patel Institute of Business Management, Computer & Information Technology, Uka Tarsadia University Unit 1 Programming Language and Overview of C 1. State whether the following statements are true or false. a. Every line in a C program should end with a semicolon. b. In C language lowercase letters are

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

Goals of C "" The Goals of C (cont.) "" Goals of this Lecture"" The Design of C: A Rational Reconstruction"

Goals of C  The Goals of C (cont.)  Goals of this Lecture The Design of C: A Rational Reconstruction Goals of this Lecture The Design of C: A Rational Reconstruction Help you learn about: The decisions that were available to the designers of C The decisions that were made by the designers of C Why? Learning

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

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

Unit 4. Input/Output Functions

Unit 4. Input/Output Functions Unit 4 Input/Output Functions Introduction to Input/Output Input refers to accepting data while output refers to presenting data. Normally the data is accepted from keyboard and is outputted onto the screen.

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

Department of Computer Applications

Department of Computer Applications 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

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

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

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

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

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

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

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

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

The Design of C: A Rational Reconstruction (cont.)

The Design of C: A Rational Reconstruction (cont.) The Design of C: A Rational Reconstruction (cont.) 1 Goals of this Lecture Recall from last lecture Help you learn about: The decisions that were available to the designers of C The decisions that were

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

CS PROGRAMMING & ATA STRUCTURES I. UNIT I Part - A

CS PROGRAMMING & ATA STRUCTURES I. UNIT I Part - A CS6202 - PROGRAMMING & ATA STRUCTURES I Question Bank UNIT I Part - A 1. What are Keywords? 2. What is the difference between if and while statement? 3. What is the difference between while loop and do

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

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

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

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

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

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

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

c) Comments do not cause any machine language object code to be generated. d) Lengthy comments can cause poor execution-time performance.

c) Comments do not cause any machine language object code to be generated. d) Lengthy comments can cause poor execution-time performance. 2.1 Introduction (No questions.) 2.2 A Simple Program: Printing a Line of Text 2.1 Which of the following must every C program have? (a) main (b) #include (c) /* (d) 2.2 Every statement in C

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

Multiple Choice Questions ( 1 mark)

Multiple Choice Questions ( 1 mark) Multiple Choice Questions ( 1 mark) Unit-1 1. is a step by step approach to solve any problem.. a) Process b) Programming Language c) Algorithm d) Compiler 2. The process of walking through a program s

More information

Full file at C How to Program, 6/e Multiple Choice Test Bank

Full file at   C How to Program, 6/e Multiple Choice Test Bank 2.1 Introduction 2.2 A Simple Program: Printing a Line of Text 2.1 Lines beginning with let the computer know that the rest of the line is a comment. (a) /* (b) ** (c) REM (d)

More information

C++ character set Letters:- A-Z, a-z Digits:- 0 to 9 Special Symbols:- space + - / ( ) [ ] =! = < >, $ # ; :? & White Spaces:- Blank Space, Horizontal

C++ character set Letters:- A-Z, a-z Digits:- 0 to 9 Special Symbols:- space + - / ( ) [ ] =! = < >, $ # ; :? & White Spaces:- Blank Space, Horizontal TOKENS C++ character set Letters:- A-Z, a-z Digits:- 0 to 9 Special Symbols:- space + - / ( ) [ ] =! = < >, $ # ; :? & White Spaces:- Blank Space, Horizontal Tab, Vertical tab, Carriage Return. Other Characters:-

More information

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

Operators. Java operators are classified into three categories:

Operators. Java operators are classified into three categories: Operators Operators are symbols that perform arithmetic and logical operations on operands and provide a meaningful result. Operands are data values (variables or constants) which are involved in operations.

More information

Prepared by: Shraddha Modi

Prepared by: Shraddha Modi Prepared by: Shraddha Modi Introduction Operator: An operator is a symbol that tells the Computer to perform certain mathematical or logical manipulations. Expression: An expression is a sequence of operands

More information

BCA-105 C Language What is C? History of C

BCA-105 C Language What is C? History of C C Language What is C? C is a programming language developed at AT & T s Bell Laboratories of USA in 1972. It was designed and written by a man named Dennis Ritchie. C seems so popular is because it is

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

KARMAYOGI ENGINEERING COLLEGE, Shelve Pandharpur

KARMAYOGI ENGINEERING COLLEGE, Shelve Pandharpur KARMAYOGI ENGINEERING COLLEGE, Shelve Pandharpur Bachelor of Engineering First Year Subject Name: Computer Programming Objective: 1. This course is designed to provide a brief study of the C programming

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

V.S.B ENGINEERING COLLEGE DEPARTMENT OF INFORMATION TECHNOLOGY I IT-II Semester. Sl.No Subject Name Page No. 1 Programming & Data Structures-I 2

V.S.B ENGINEERING COLLEGE DEPARTMENT OF INFORMATION TECHNOLOGY I IT-II Semester. Sl.No Subject Name Page No. 1 Programming & Data Structures-I 2 V.S.B ENGINEERING COLLEGE DEPARTMENT OF INFORMATION TECHNOLOGY I IT-II Semester Sl.No Subject Name Page No. 1 Programming & Data Structures-I 2 CS6202 - PROGRAMMING & DATA STRUCTURES UNIT I Part - A 1.

More information

Introduction to C. History of C:

Introduction to C. History of C: History of C: Introduction to C C is a structured/procedure oriented, high-level and machine independent programming language. The root of all modern languages is ALGOL, introduced in the early 1960. In

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

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

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

Unit 3 Decision making, Looping and Arrays

Unit 3 Decision making, Looping and Arrays Unit 3 Decision making, Looping and Arrays Decision Making During programming, we have a number of situations where we may have to change the order of execution of statements based on certain conditions.

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

Objectives. Chapter 2: Basic Elements of C++ Introduction. Objectives (cont d.) A C++ Program (cont d.) A C++ Program

Objectives. Chapter 2: Basic Elements of C++ Introduction. Objectives (cont d.) A C++ Program (cont d.) A C++ Program Objectives Chapter 2: Basic Elements of C++ In this chapter, you will: Become familiar with functions, special symbols, and identifiers in C++ Explore simple data types Discover how a program evaluates

More information

Chapter 2: Basic Elements of C++

Chapter 2: Basic Elements of C++ Chapter 2: Basic Elements of C++ Objectives In this chapter, you will: Become familiar with functions, special symbols, and identifiers in C++ Explore simple data types Discover how a program evaluates

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

The Design of C: A Rational Reconstruction (cont.)" Jennifer Rexford!

The Design of C: A Rational Reconstruction (cont.) Jennifer Rexford! The Design of C: A Rational Reconstruction (cont.)" Jennifer Rexford! 1 Goals of this Lecture"" Help you learn about:! The decisions that were available to the designers of C! The decisions that were made

More information

Fundamentals of C. Structure of a C Program

Fundamentals of C. Structure of a C Program Fundamentals of C Structure of a C Program 1 Our First Simple Program Comments - Different Modes 2 Comments - Rules Preprocessor Directives Preprocessor directives start with # e.g. #include copies a file

More information

Chapter 2: Basic Elements of C++ Objectives. Objectives (cont d.) A C++ Program. Introduction

Chapter 2: Basic Elements of C++ Objectives. Objectives (cont d.) A C++ Program. Introduction Chapter 2: Basic Elements of C++ C++ Programming: From Problem Analysis to Program Design, Fifth Edition 1 Objectives In this chapter, you will: Become familiar with functions, special symbols, and identifiers

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

Continued from previous lecture

Continued from previous lecture The Design of C: A Rational Reconstruction: Part 2 Jennifer Rexford Continued from previous lecture 2 Agenda Data Types Statements What kinds of operators should C have? Should handle typical operations

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

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

Reserved Words and Identifiers

Reserved Words and Identifiers 1 Programming in C Reserved Words and Identifiers Reserved word Word that has a specific meaning in C Ex: int, return Identifier Word used to name and refer to a data element or object manipulated by the

More information

Operators and Expressions:

Operators and Expressions: Operators and Expressions: Operators and expression using numeric and relational operators, mixed operands, type conversion, logical operators, bit operations, assignment operator, operator precedence

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

E.G.S. PILLAY ENGINEERING COLLEGE (An Autonomous Institution, Affiliated to Anna University, Chennai) Nagore Post, Nagapattinam , Tamilnadu.

E.G.S. PILLAY ENGINEERING COLLEGE (An Autonomous Institution, Affiliated to Anna University, Chennai) Nagore Post, Nagapattinam , Tamilnadu. 7CA00 PROBLEM SOLVING AND PROGRAMMING Academic Year : 08-09 Programme : P.G-MCA Question Bank Year / Semester : I/I Course Coordinator: A.HEMA Course Objectives. To understand the various problem solving

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

Computers Programming Course 7. Iulian Năstac

Computers Programming Course 7. Iulian Năstac Computers Programming Course 7 Iulian Năstac Recap from previous course Operators in C Programming languages typically support a set of operators, which differ in the calling of syntax and/or the argument

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

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

Tutorial No. 2 - Solution (Overview of C)

Tutorial No. 2 - Solution (Overview of C) Tutorial No. 2 - Solution (Overview of C) Computer Programming and Utilization (2110003) 1. Explain the C program development life cycle using flowchart in detail. OR Explain the process of compiling and

More information

Introduction. Following are the types of operators: Unary requires a single operand Binary requires two operands Ternary requires three operands

Introduction. Following are the types of operators: Unary requires a single operand Binary requires two operands Ternary requires three operands Introduction Operators are the symbols which operates on value or a variable. It tells the compiler to perform certain mathematical or logical manipulations. Can be of following categories: Unary requires

More information

Data types, variables, constants

Data types, variables, constants Data types, variables, constants 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 in C 2.6 Decision

More information

Data Types and Variables in C language

Data Types and Variables in C language Data Types and Variables in C language Disclaimer The slides are prepared from various sources. The purpose of the slides is for academic use only Operators in C C supports a rich set of operators. Operators

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

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

COMPUTER SCIENCE HIGHER SECONDARY FIRST YEAR. VOLUME II - CHAPTER 10 PROBLEM SOLVING TECHNIQUES AND C PROGRAMMING 1,2,3 & 5 MARKS

COMPUTER SCIENCE HIGHER SECONDARY FIRST YEAR.  VOLUME II - CHAPTER 10 PROBLEM SOLVING TECHNIQUES AND C PROGRAMMING 1,2,3 & 5 MARKS COMPUTER SCIENCE HIGHER SECONDARY FIRST YEAR VOLUME II - CHAPTER 10 PROBLEM SOLVING TECHNIQUES AND C PROGRAMMING 1,2,3 & 5 MARKS S.LAWRENCE CHRISTOPHER, M.C.A., B.Ed., LECTURER IN COMPUTER SCIENCE PONDICHERRY

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

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

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

Advanced C Programming Topics

Advanced C Programming Topics Introductory Medical Device Prototyping Advanced C Programming Topics, http://saliterman.umn.edu/ Department of Biomedical Engineering, University of Minnesota Operations on Bits 1. Recall there are 8

More information

Princeton University Computer Science 217: Introduction to Programming Systems The Design of C

Princeton University Computer Science 217: Introduction to Programming Systems The Design of C Princeton University Computer Science 217: Introduction to Programming Systems The Design of C C is quirky, flawed, and an enormous success. While accidents of history surely helped, it evidently satisfied

More information

Programming - 1. Computer Science Department 011COMP-3 لغة البرمجة 1 لطالب كلية الحاسب اآللي ونظم المعلومات 011 عال- 3

Programming - 1. Computer Science Department 011COMP-3 لغة البرمجة 1 لطالب كلية الحاسب اآللي ونظم المعلومات 011 عال- 3 Programming - 1 Computer Science Department 011COMP-3 لغة البرمجة 1 011 عال- 3 لطالب كلية الحاسب اآللي ونظم المعلومات 1 1.1 Machine Language A computer programming language which has binary instructions

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

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

CSCI 171 Chapter Outlines

CSCI 171 Chapter Outlines Contents CSCI 171 Chapter 1 Overview... 2 CSCI 171 Chapter 2 Programming Components... 3 CSCI 171 Chapter 3 (Sections 1 4) Selection Structures... 5 CSCI 171 Chapter 3 (Sections 5 & 6) Iteration Structures

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

Overview of C. Basic Data Types Constants Variables Identifiers Keywords Basic I/O

Overview of C. Basic Data Types Constants Variables Identifiers Keywords Basic I/O Overview of C Basic Data Types Constants Variables Identifiers Keywords Basic I/O NOTE: There are six classes of tokens: identifiers, keywords, constants, string literals, operators, and other separators.

More information

C++ Programming Basics

C++ Programming Basics C++ Programming Basics Chapter 2 and pp. 634-640 Copyright 1998-2011 Delroy A. Brinkerhoff. All Rights Reserved. CS 1410 Chapter 2 Slide 1 of 25 Program Components Function main P Every C/C++ program has

More information

Informatics Ingeniería en Electrónica y Automática Industrial

Informatics Ingeniería en Electrónica y Automática Industrial Informatics Ingeniería en Electrónica y Automática Industrial Operators and expressions in C Operators and expressions in C Numerical expressions and operators Arithmetical operators Relational and logical

More information

OBJECT ORIENTED PROGRAMMING

OBJECT ORIENTED PROGRAMMING OBJECT ORIENTED PROGRAMMING LAB 1 REVIEW THE STRUCTURE OF A C/C++ PROGRAM. TESTING PROGRAMMING SKILLS. COMPARISON BETWEEN PROCEDURAL PROGRAMMING AND OBJECT ORIENTED PROGRAMMING Course basics The Object

More information

INTRODUCTION 1 AND REVIEW

INTRODUCTION 1 AND REVIEW INTRODUTION 1 AND REVIEW hapter SYS-ED/ OMPUTER EDUATION TEHNIQUES, IN. Programming: Advanced Objectives You will learn: Program structure. Program statements. Datatypes. Pointers. Arrays. Structures.

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