Open navigation menu
Close suggestions
Search
Search
en
Change Language
Upload
Sign in
Sign in
Download free for days
0 ratings
0% found this document useful (0 votes)
165 views
41 pages
10th Computer Chapter 2 Notes Ilmkidunya
Uploaded by
tt
AI-enhanced title
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here
.
Available Formats
Download as PDF or read online on Scribd
Download
Save
Save 10th-computer-chapter-2-notes-ilmkidunya For Later
Share
0%
0% found this document useful, undefined
0%
, undefined
Print
Embed
Report
0 ratings
0% found this document useful (0 votes)
165 views
41 pages
10th Computer Chapter 2 Notes Ilmkidunya
Uploaded by
tt
AI-enhanced title
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here
.
Available Formats
Download as PDF or read online on Scribd
Carousel Previous
Carousel Next
Download
Save
Save 10th-computer-chapter-2-notes-ilmkidunya For Later
Share
0%
0% found this document useful, undefined
0%
, undefined
Print
Embed
Report
Download
Save 10th-computer-chapter-2-notes-ilmkidunya For Later
You are on page 1
/ 41
Search
Fullscreen
UNIT 2 User Interaction Q. What is computer and output function? A computer is a device that takes data as input, process that data and generates to ‘output. While output function is used to get data from the program. Output produced by monitor is called standard output. C language offers printf function to display the output. Q. Explain the printf{) function of C language with an example. (or) What function of C language is used to display output on screen? printf: printf is @ builtin function in C programming language to show output on screen. Its name comes from “print formatted’ that is used to print the formatted output on screen. Al data types can be displayed with printf function. To understand the working of printf function, consider the following programming example: Example: Program ‘Outpi Finclude
void main() { Hello World printf(“Hello Werld); } In this example, printf function is used to display Hello World on screen. Whatever we write inside the double quotes “and” in the printi() function, gets displayed on screen Q. Why format specifiors are important to be specified in 1/0 (Input/Output) operations? Format specfier represents data type field width and format of a value of a variable displayed on the screen. A format specifier always begins witn the symbol %. Format specifiers are used for both input and output statements, The general syntax of format specifier is. % Example: It we want to display the value of a variable? Let's deciare a variable and then check the behaviour of print int age = 35; Now | want to display the value of this variable age on screen. So, | write the following statement: printi(‘age’), But, it does not serve the purpose, because it displays the following output on screen, age It does not display the value stored inside the variable age, instead it just displays whatever was written inside the double quotes of printf. In fact, we need to specify the format ofdata that we want to display, using format specifiers, Following table shows format specifiers against ditferent data types in C language. Data type Format Specifier int % dor % | float SF char %e ‘Suppose we want to show int type data, we must specify it inside the printf by using the format specifier % d or %i, In the same way, for float type data we must use %f. It is shown in the following example: Example: Program: Binclude
include
void main() ( cirser() float height = 5.8; int age = 35; printf(" My age is %d and my height is %f ", age, height); y getehdr Output: My age is 35 and my height is 5.800000 We can observe that while displaying output, first format specifer is replaced with the valve of first variable/data after the ending quotation mark ie. age in the above example, and second format specifier is replaced with the second variable/data When wo use %f to display a float value, it display 6 digits ater tho decimal point. If wo want to specify the number of digits after decimal point then we can write %.nf where n is the number of Cigits. In the above example, if we write the following statement Example: Program Finclude
#include
void main() © ese float height = 5.8; int age= 35; print(* My age is %d and my height is %. 21*, age, height); getch() Format specifiers are not only used for variables. Actually they are used to display the result of any expression involving variables, constants, or both, as shown in the example below.Example: Program Hinclude
itinclude
Output void main() ‘ cirser(); printi("Sum of 23 and 45 is %d", 23 + 45); getch(); Q. Write a note on scant? scant: scanf is a built-in function in C language that takes input from user into the variables. We specify the expected input data type in scanf function with the help of format specifier If user enters integer data type, format specifier mentioned in scanf must be %d or %i Consider the following example. Fincude=stdio ne Sinctodeseorio.t> void main() { etrsery: char grade; seani("%e", Bgrade) } getch(); In this example, %c format specifier is used character type for the input variable. Input entered by user is saved in variable grade. There are two main parts of scanf function as it can be seen from the above code. First part inside the double quotes is the list of format specifiers and second partis the list of variables with & sign at their loft Exampl Program Finclude
#include
fe main() Output elrser(); Enter a number between 0-10: 4 int number, The number you entered is 4 printf(‘Enter a number between 0-10: scanf(‘%d", &number); printf(‘The number you entered is: %d", number); getch();We can take multiple inputs using a single scanf function e.g. consider the following statement scanf("%d%d%", &a, &b, &c); It takes input into two integer type variables a and b, and one float type variable c. After each input, user should enter a space or press enter key, After the entire input user must press enter key. It is @ very common mistake to forget & sign in the scanf function, Without & sign, the program gets executed but does not behave as expected. Q: Write a note on getchi)? geteh(): ‘getch() function is used to read a character from user. The character entered by user does not get displayed on screen, This function is generally used to hold the execution of program because the program does not continue further until the user types a key. To use this function, we need to include the library conio.h in the header section of program. Examp! Fincudesstdioh> lude
void main() elrser(); print{(“Enter any key if you want to exit program’); getch(); ‘The above program wants user to enter any key and then waits for the user's input before finishing the execution of program, Examp! Finchidesstsion> ‘#includesconio.n> void main() { clrscr(); cher printf("Enter any key:"); ‘ key = getch(); // Gets a character from user into variable key getch(); if we run this program. we notice a difference between reading a character using scant and reading a character using getch functions. When we read character through scanf, it requires Us to press enter for further execution. But in case of getch, it does net wait for enter key to be pressed, Function reads a character and proceeds to the execution of next line.Q, Write a note on cirscr()? elrser(); ‘This function is used to clear the oulpul screen of C language editor. Example: Program, Finclude
#include
void main() Output { Enter a number between 0-10: 4 | clscr() ‘The number youentered is: 4 int number: printf“Enter a number between 0-10.) scan{("%d", &number); printf"The number you entered is: %d", number); getch(); Q. What is a Statement Terminator? Statement Terminator: ‘A statement terminator is identifier for compiler which identifies end of a line. In C language semi colon (;) is used as statement terminator. If we do not end each statement with 9; it results into error printf("Hello World") GL_(;)-»exaterment, Q. What are escape sequences? Why do we need them? Escape Sequenci Escape sequence are used in printf functioh inside the double quotes (‘ "). it force print to change ts normal behaviour of showing output. Let's understand the concept of an escape sequence by consicering the folowing example statement: printf (My name is AI\"*); The output of above statement is: My name Is “Ali” In the above example \" is an escape sequence. It causes printf to display ‘on computer screen". Formation of escape sequence Escape sequence consist of two characters. The first character is always back slash (\) and the second character varies according to the functionality that we want to achieve. Back slash (\) is called escape character which is essociated with each escape sequence to notify about escape. Escape character and character next to it are not displayed on screen, but they perform specific task assigned to them, The following escape sequences are also commonly used in C languages”‘Sequence Purpose ‘Sequence Purpose v Display Single Quote (') la Generates an alert sound w Display Back siash(\) tb Removes previous char ie Display 8 spaces tn Move on next line Now tine (\n) After escape character, n specifies movement of the cursor to start of the next line, This escape sequence is used to print the output on multiple lines, Example: Program #include
#include
rma void main() ‘Output ] { My name is Ali, Slower) | live in Lahore printf(’My name is Ali. \n"); printf"! live in Lahore getchi); In the ebsence of an escape sequence, even if we have multiple printf statement, their output is displayed on a single line, Following example illustrates their point. Example: Program #include
‘#include
void main() { clrsert); printMy name printf("Ahmad? getch(); ‘Output ‘My nameis Ahmad ) Tab (\t) Escape sequence \t specifies the 1/0 function of moving to the next tab stop horizontally. A tab stop is collection of 8 spaces. Using It takes cursor to the next tab stop. This escape sequence is used when user presents data with more spaces.Finclude
#include
‘oid main) Output , Name: Ali clrser(); Fname: Hammad printf("Name: \tAl\inFname: \tHammad\nMarks: \t1000"); Marks: 1000 getch() Q. What aro Operators? Operators: Operators are the mathematical symbols that perform some operation on operands. ‘Operands are the values or variables. There are many operators used in C language, some of these are: * Assignment operator * Arithmetic operator + Logical operator ‘+ Relational operator Q. Explain Assignment Operator. Assignment Operator: ‘ Assignment operator is used to assign a value to a variable, or assign a value of variable to another variable. Equal sign (=) is used as assignment operator in C. Consider the following example: int sum = 5; Values 5 is assign to a variable named sum afer executing this line of code. Let's have a look at another example: Int sum = Int var = eum; First, value 6 is assign to variable sum. in the next line, the value of sum is assigned to variable var. Example: Write s program that swaps the velues of two Integer variables. Finclude
#include
void main() { clrscr(); inta= 2, b= 3, temp; temp= a a=b b= temp; Printf“Value of a after swapping: Yed\n”, 2); printf("Value of b after swapping: Yed\n. b): getch(),Q, Which operators are used for arithmetic operations? Arithmetic Operators: Arithmetic Operators ate used to perform arithmetic operations on data. Following table represents arithmetic operators with their description. ‘Operator _[ Name Description Tris used to divide the value on left side by the value on ! Division Operator | right sige : ‘Multiplication Operator | 118 used to multiply two values. + ‘Addition Operator _| [tis used to add two values This used to subtract the value on right side from the - Subtraction Operator | value on lett side. Tegives remainder value after dividing the left operand by right operand, % Medulus Operator Division Division operator (/) divides the value of left operand by the value of right operand. 2.9. float result = 3.0/2.0; Afor the statement, the variable result contains the value 1.5 If both the operands are of type int, then resutt of division is also of type int. Remainder is truncated to give the integer answer. Consider the following line of code. float result = 3/2; ‘As both values are of type int so answer is also an integer which is 1. When ihe value 1 is assigned to the variable result of type “oet, then this 1 is converted to float, so value 1.0 is stored in variable result If we want to get the precise answer then one of the operands must be of floating type. Consider the following line of code: float result = 3.0/2; In the above example, the value stored in variable result is 1.5. Example: Write @ program takes as input the price of a box of chocolates and the total number of chocolates in the box, The program finds and displays the price of one chocolate.Program Finclude=sidio.h> #include
void main() { errser() float box_price, num_ol_chocolates, unit_price; print("Please enter the price of whole box of checolates:"); scant("Sef *, &box_price); print("Please enter the number of chocolates in the box") seanf(‘Sof”, &num_of_chocolates); tunit_price = box_price / num_of chocolates: print(“The price of a single chocolates is: %e’, unit price): getch(); } Output Please enter the price of whole box of chocolates: 150 Please enter the number of chocolates in the box: 50 The price of a single chocolates is: 3.000000 Multiplication ‘Multiplication operator (*) is a binary operator which performs the product of two numbers. e.g. int multiply = 5 §; ‘After the execution of statement, the variable muttipy contains value 25 Example: Write a program that takes as input the length and width of a rectangle. Program calculates and displays the area of rectangle on screen. Program ¥include
#include
void main() ( eteser(; float length, width, area; print("Please enter the length of rectangle: scant("%f", &length); print("Please enter the wicth of rectangle:"); scani("%f*, &width); area = length * width; print(“Area of rectangle is: %f*, area); getch(); ‘Output Please enter the length of rectangle’ 6 5 Please enter the width of rectangle: 3 ‘Area of rectangle is: 19.500000Addition Addition operator (+) calculates the sum of two operands. e9. intadd = 10+ 10; Resultant values in variable add is 20 Example: Write a program that takes marks of two subjects from yser and displays the sum of ‘marks on console, Program Fincude
: fincludesconio.h> void main) { clrser(); int sum, math, science; print"Enter marks of Mathematics: scanf(‘%d", &math); printf("Enter marks of Science:’); scant("%d", &sclence); sum = math + science, printf("Sum of marks is : %d", sum); getchi); , Output Enter marks of Mathematics: 90 Enter marks of Science: 80 ‘Sum of marks is: 170 The statement a = a + 1; is used to increase the value of variable a by 1. In C language, this statement can also be writen as a++; or +a; Similarly, a --jor-~ a used to decrease the value of a by 1. Subtraction Subtraction operator (-) subtracts right operand from the let operand. 9. _Introsult = 20 ~ 15; After performing subtraction, value 5 is assigned to the variable result Modulus operator Modulus operator (%) performs divisions of left operand by the right operand and returns the remainder value after division. Modulus operator works on integer data types. 29. Intremalning = 14% 3; As, when we divide 14 by 3, we get remainder of 2, so the value stored in variable remaining is 2.Example: Write a program that finds and displays the right most digit of an input number. Program Finclude
#includeeconio.h> — main() copii clrser(); Entera number: 769 int num, digit; Right most dig of number you entered is: 9 prind("Enter @ numb ‘scanf(“%ed", &num); digit = num % 10; print((“Right most digit of number you entered is: %d", digit); getchi), } ‘While writing arithmetic statement is C language, a common mistake is to follow the usual algebraic rules e.g. writing 6 * y as Gy, and writing x * x* x as x’ ete, It results in a compiler error. Q. What are relational operators? Describe with an example. Relational Operators: Relational operators compare two values fo determine the relationship between values. Relational operators identify either the values are equal, not equal, greater than or less than one another. C language allows us to perform relational operators on numeric and char type data. The basic relational operators with their description are given below: Relational Operator Description == Equaite T= Not equal > Greator than < Less than oe Greater than equal to <= Less than equal to Relational operators perform operations on two operands and return the result in Boolean expression ((rue or false). A true value is represented by 1, whereas a false value is represented by a0. This concept is further shown in following table; Relational Expression Explanation Result 5=25 Sis equalto5? True S17 ‘Sis not equal 77 True 37 Sis greater than 77 False 3<7 Sis less than 7? True §>=5 Sis greater than or equalto 5? True S<94 5 is less than or equalto 4? FalseQ. What is the difference between == operator ant Assignment operator (=) and equal to operator ( In C language, == operator is used to check for equality of two expressions, whereas = ‘operator assigns the result of expression on right side to the variable on left side. Double equal ‘operator (==) checks whether right and lef operands are equal or not. Single equal operator (=) assigns night operand to the variable on lef side. We can also use print function to show the result ofa relational expression, e.g. Consider the following examples. printt("%d", == 5); // This statement displays 1 printt( %ed” , § > 7); // This statement displays 0 operator’ Q. What are logical operators? Describe with an example. Logical Operators: Logical operators perform operations on Boolean expression and produce a Boolean expression as a result, The result of a relational operation is a Boolean expression, Logical operators can be performed to evaluate more than one relational expression. Following table shows the basic logical operators and their description Operator Description a8 Logical AND i Logical OR Logical NOT AND operator (&&): ‘AND operator && takes two Boolean expressions as operands and produces the result true if both of its operands are true, it retums false if any of the operands is false. The trutn table for AND operator Is shown below. [Expression 1 Operator Expression 2 Result False Bb False False False && True False True 8a False False True aa True True OR operator (|): OR operator accepts Boolean expression and returns true if at least one of the operands is true. The truth table for OR operator is shown below: Expression 1 Operator Expression 2 Result False i False False False I True True True, IL False True True i True TrueNOT operator (I): NOT operator negates or reverses the value of Boolean expression, | makes it rue, ifit is false and false if itis true. The truth tabie for Not operator is given below: Expression Operator Result True 7 False False r True Examples of Logical Operators: Following tabla shows the concept of logical operators with the help of examples. Logica! Expression ‘Explanation Result 3<4887>6 | Sisless than 4 AND 7 is greater than 8 7 | False 4{/3>1 | 3is ecualto4 OR 3 is greater than 1 ? True (4>2\12==2) | Not (ais greater than 2 OR 2 is equalto 2) 7 | False 8<=68A1(1> 2) | Gisless than orequalto § AND NOT (1 is greaterthan2)?) True Bray Bis greater than @ OR NOT (1 is less than er equal ta0)? | True language performs short-circuit evaluation, means tat 4: While evaluating an AND operator, if sub expression at left side of the operator is false then the result is immediately declared as false without evaluating complete expression, 2: While evaluating an OR operator, if sub expression at left side of the operator is true then the result is immediately declared as true without evaluating complete expression, Q What is the difference between unary operators and binary operators? Unary vs Binary Operators: All the operators discussed can be divided into two basic types, based on the number of ‘operands on which the operator can be applied Unary Operators: Unary operators are appied over one operand only e.g. logical NOT (|) operator has only fone operand. Sign operator (-) is another example of @ unary operator eg. -5. Binary Opsrators: Binary operators require two operands to perform the operation e.g. all the arithmetic operators, and relational operators are binary operators. The logical operaiors && and j| are also ___ binary operators. Ternary Operator: The operator offers three operands in C programming Language is called ternary operator. .Q. What is meant by precedence of operators? Which operator has the highest precedence in languag Operator's Precedence: If there are muttipte operators in an expression, the question arises that whicn operator is evaluated first. To solve this issue, precedence has been given to each operator. An operator with higher precedence is eveluated before the operator with lower precedence. in case of equal precedence, the operator at left side Is evaluated before the operator at right sid jerator Precedence 1 Lk w= Examplk result= 18/2°3+7%3+(5* MH evaluate () result= 18/2'3+7%3 + 20; Mevaiuate | result=9°3+7% 3+ 20; Jevatuate " result= 27 +7.% 3 +20; HM evaluate % result= 27 +1 +20; MH evaluate + result = 28 + 20; MW evaluate + result= 48;oir Q.1__ Multiple Choice Question: Sr. KS Question A B c D 1. | printis used to print __type of data, int float chor | allot those Beant 1 @ in © programming none oF tee Keyword | Library | Function | RR getch() is used to take as input | 3. | Semucer int float char | Allof these Tet the following part of code, what wil Be 4 | the value of variable a atter execution: 88 e 80 az inta=4ifloatb=22; a=a*bi 5 | Win of the folowing i= & vat Tins of Tine =this | none of code? isatine; | these | Which eperater has highest precedence | . x A ‘among the following’ 7, | Mic of te folowing is not 3 type ct | arinmatic| Check | Relational | Logical operator: operator | operator | operator | operator a | THe Oberaior % is used To CHIEU |p aae| Remainder | Factorial | Square | Which “of the following is a vaild ae a None of character. these Cis nota kis Alllogical 10. | Whatis true about ¢ language: case | -wsedian) | Spears.) (Mensa sensitve | (haue |aebinary| these fanguage | “reg | operators KEY: 1 z a a 5 € T 3 0 D AB D 3S 5 a 5 c D Q.2 True or Fal 4. Maximum value that can be stored by an integer is 82000 TF 2. Format specifiers begin wth a % sign. Tr 3. Precedence of division operators greater than multiplication operator. vr 4, getch is used to take all types of data input from user. Tr 8. _scanfis used for output operations. Tr Key: i 2 a 4 5 F T F T FQ.3_ Define the following: 1) Statement Terminator 2) Format Specifier 3) Escape Sequence 4) scant 5) Modulus Operator Q.4 Briefly answer the following questions, 1) What is the difference between scanf and getch? 2) What function of C tanguage is used to display output on screen? 3) Why format specifiers are important to be specified in VO operations? 4) What are escape sequences? Why do we need them? 5) Which operators are used for arithmetic operations? 6) What are relational operators? Describe with an example. 7) What are fogical operators? Describe with an example. 8) What is the difference between unary operators and binary operators? 9) What is the difference between == operator and = operator? 10) What is meant by precedence of operators? Which operator has the highest precedence in © language? Q.5 Write down output of the following code segments. Seo Page No. 33 ‘Seo Pago No. 25 Seo Page No. 33 ‘See Page No. 31 ‘See Pago No. 38 See Page No. 69 See Pago No. 29 Seo Page No. 29 See Page No. 33 ‘See Page No. 36 See Pago No. 39 See Page No. 40 See Page No. 41 Soe Pago No. 40 ‘See Page No. 42 a) tincludecstdio.h> ae void main() 07,8 { intk=2,y=3,2=6 intans1, ans2, ans3; x12" y, yrzly*2; ans3=2/x+x"y, print("%d %d %a", ans, ans2, ans3); b) — #include
void main() Cute f printf(’nn nin nnn inn nt Wt}: ann print{("nn fev nnv/nin’) A } t nn ininaninc) —-#include
void main() ¢ inta=4, b; floate = 2.3; beers, printf(“%ed", b); ' qd) #include
void main) { inta=4°3/( 541) 97% 4; printed", a), } e) — #inciude
void main) prinif("%d", (((5 > 3) && (4 > 6)) 1 (7 > 3); } Q.6 Identity errors in the following code segments. a) Bincude
void main() { inta.b b=a%2; print("Value of b is: %d, by; 3; ) b) — #include
void main() { inka. b,c, print(*Enter First Number); scanf("Sod", 8a), print{("Enter second number: scan{("‘d", &b): arb=c, } ©) tinckide
void main() { int num, print(Enter Number scanf(%d, &num); Output: 9 ‘Output: 5 Output: 4 Error: Value of variable a is not initialized, Inverted comma is missing ater %d Error: Semicolon is missing after int variable, invalid syntax of a+ b= ¢;, The correct syntaxis cxa+b; Error: Double quotes missing in printt statement and ) has extra4) #inctudessidio.he — void meaint) Square bracket is used instead of { parentheses. In printf statement float variable float f is used with ‘6th scant instead of Ye. print'Enter value"); scani("%c", Bf) Progi fe Exercise 1 The criteria for calculation of wages in a company are given below: Basie Selary = Pay Rale Per How Worlang Hours of Employee Overtime Salary = Overtime Pay Rate X Overtime Hours of Employee Total Salary = Basic Salary + — Overiime Salary Write @ program that should take working hours and overtime hours of employee as input. The Program should calculate and display the total salary of employee. Program Finelude
#include-
void maint) 8 elrser(); int wh,oh,rate_per_hour.otrate,basic_salary.overtime_salary.total_ealary; print{('Entar Working Hours of Employ:" scanf('%d", wh): . printfEnter overtime working hours); scanf('%ed",&oh); print{"Enter rats par hours: scenf('%d",Brale_per_hour}; printf("Enter over Time rate per hour: scant('%d" Boat basic. salary = wh'rate_per_hour; overtime_satary = oh’otrate {otal_salary = basic_salaryrovertime_salary; printf("Total salary is = %éd":total_salery) getch); } Ouiput Enter Working Hours of Employ 20 Enter overtime working hours: 10 Enter rate per hours: 20 Enter over Time rate per hour: 10 Total Salary is = 500Exercise 2 . Write 2 program that takes Celsius temperature as input, converts the temperature into Fahrenheit and shows the output Formula for conversion of temperature from Ceisius to Fahrenheit is: Fezc+2 Program Yinclude
#includesconio.n> int main() { elrser(: float celsius, fahrenheit; print"Enter temperature in Celsius: "); scani(‘%ét", &celsius) licelsius to fahrenheit conversion formula fahrenheit = (celsius *9/5) + 32: printl('Celsius =% 2f Fahrenheit=%,2f", celsius, getcnd); hrenheit) 1 ‘Output Enter temperature in Celsius: 37 Celsius = 27.00 Fahrenheit = 98.60 Exercise 3 Write program that display the following output using single printf statement 1 z 3.4 Program include
int main() { printf" “it Ne “inte 2 34 4"); } : Oulput 42 a4Exercise 4 ite a program that displays the following output using single prinif statement: lam a Boy Live in Pakistan Jam a Proud Pekistani Program Fnclude
#include
int main() clrscn); print{( am a boy \n | live in Pakistan \nt am @ Proud Pakistani") geen) } Output Tam Boy Live in Pakistan Jam a Proud Pakistani Exercise 5 A clothing brand offers 15% ciscount on each item A lady buys 5 shirts from this brand. Write 2 program that calculates total price after discount and amount of discount availed by the lady. Original prices of the shins are: Shirtt = 432 Shirt2 = 320 Shirt3 = 270 Shirté = 680 ShirtS = 620 Note: Use § variables to store the prices of shirts.Program Finelude=atdio n> include
int main() f cirser(); int shirt] = 423, shirt2 = 320, shirt: float totaiprice, totaldiscount. finalprice; printf('First Shirt price Yd \t\t Discount ws %.2f \t Payable price: %.2 | \n' shirt, (shirtt"0.15), (shiett-(shirtt*0.18))); printf('Second Shirt price: %d \t Discount is %.2f\t Payable price: %.2f \n",shirt2, (shirt2*0.15), (shirt2-(shit2*0.1))); printf("Third Shirt price: %d \t \t Discounts %.2f \t Payable price: %.21 Wn',shirt3, (shirt3°0.15), (shirt3-(shirt3"0,15)), print(*Fcurth Shirt price: %d\t Discount is % 2F \t Payable price %.2f \n.shins, (shirté"0 18), (shirté-(shirt4r0.15)); print'Fith Shit price: %d \t\t Discount is %.2f \t Payable price: % 21 \n' shit, (shirtS70.1), (shirt5-(shirt5*0.15))); printf("\nin——- totalprice = shirt + shirt2 + shirt3 + shirt4 + shir totaldiscount = (shirt1*0.15)+(shirt2*0. 15)+(shit3°0.15)+(shirt4"0.15)+(shirt6"0.15); finaiptice = (shirt1-(shirt1"0.15))+(shint2-(shirt2‘0. 15)}+(shirt3-(shit3°0. 15))+(shirts ~ (shirt4*0.15))+(shitS-(shirt5*0.15)); . printf("Total price: %.2f \! Total Discount is %.2 it Final price: %.2F\ntotalprice, totaldiscount, finalprice); 70, shind = 680, shitS = 520; ey geich(); } ‘Output First Shin Price 423 Discount is 63.45 Payable price: 350.55 Second Shirt Price : 320 Discount is 48.00 Payable price: 272.00 Thid Shin Price 270 Discount is 40.50 Payable price: 329.60 Fourth Shirt Price 680 Discount is 102.00 Payable price: 578.00 Fifh Shirt Price 520 Discount is 78.00 Payable price: 442.00 Total Price: 2213.00 Tolal Discount is 331.95 Final price: 1881.05Exercise 6 White a program that swaps the values of two integer variables without help of any third variable, Program z #include
#include
int main() { clrser(): int a*10, b=20, print{("Before swap a=%d b=%d",a,b); aeatb; 1/3=30 (10+20) bead, 0=10 (30-20) aza-b, W/a=20 (30-10) print("WAfter swap =%d bea getch(); y ‘Output Before swap a= 10 =20 Aferswap a= 20b=10 Exercise 7 White a program that takes a 5 digit number as input, calculates and dispiays the sum of first and last digit of number. Program Finclude
‘#include
int main() { errser(); int number; print"Enter a number with length 5 digts:"); scank"%d",&number); print{("The sum of first and Sth digit is: Sed, (number / 10000) + (number %10)); geten(); } ‘Sutput Enter @ number with length 5 cigits: 12345 ‘The sum of first and Sth digit is: 6Exercise 8 ‘Write a program that takes monthly income and monthly expenses of the user like electricity bill, gas bill and food expense, Program should calculate the following: + Total monthly expenses + + Totally yearly expenses + Monthly savings : Yearly saving ‘Average saving per month ‘Average expense per month Program Finclude
#include
int main() { elrser(); monthly_savings; scanf("%a",&monthiy_income); rinif("in\n\tYour Electricity Bil); scanf("%d" Belectricity_bil); prinif("t¥our Gas Bit: scanf("%d",&gas_bill); prinf("tY our Food Expense: ") scanf("%d",&food_expense), monthly_Expenses = electrcity_bill printi("Please enter your Monthly Income: int monthly_Income, electricity_bill, gas_bill, food_expense, monthly Expenses, prini(Please enter you Monthly Expenses: °); + gas_bill + food_expense: printf("ininit Total Monthly Expenses are: Yeq", monthly Expenses), printf("init Total Yearly Expenses are: %d' monthly_savings = monthly_income-monthly Expenses, prinif("inin\t Your Monthly savings is: Yed", monthly_savings); prinif("in\t Your Yearly savings is: %d', monthly_savings"12); prinif("ininit Average saving per month: %d", monthly_savings); " (monthiy_Expenses)"12); print("n\t Avarage expense per month: Sd", monthly_ Expenses): geteh(); 1 : ‘Output Please ener your Monthly Income: 63000 Please enter your Monthly Expenses ‘Your Electricity Bill ‘Your Gas Bill Your Food Expense Total Monthly Expenses are Total Yearly Expenses are ‘Your Monthy Saving is Your Yearly Saving is ‘Average saving per month Average expense per month 2300 500 22000 24800 297600 38200 458400 : 38200 24800Exercise 9 ‘White @ program that takes a character and number of steps as input from user. Program should then jump number of steps from that character. Sample output: Enter character a Enter steps: 2 Enter character: © Program | Yinclude
int main() cirser(), char ¢; int steps; printf(“Enter character: "); scani("%c’ 8c); printh("\nEnter Steps: "); scanf("%d" &steps), Intx=c + steps; printf("\WNew Character: %e" x); een ‘Output Enter character: a Enter steps: 2 |New Character: ¢ =f Exercise 10 Write 2 program that takes radius of a circle as input. The program should calculate and display the area of circie. Program finclude
#nclude
Int main() ceser(): float radius; prinf("Please enter the radius of circle: *); scant" %f", radius); print" Area of circle ws: %.21, 3.14*radius"radius); getch(); } ‘Ouiput Piease enter the radius of circle: 20 Area of circle is: 1256.00Beir Activity 24 Write down the output of following code: Finclude
#includesconio.h> voic main() cirser(); print"! am UPPERCASE and this Is lowercase’); geteh(): ) Oulput Tam UPPERCASE but this is lowercase ‘Retivity 22 Waite @ program thet shows your first name in Uppercase and yaur last name inlower case letter on screen, Finelude
#include
int main() alrseri); printf MUBASHIR hussain’); geteh(): ) Output MUBASHIR hussain‘Retivity 2.3 ‘Write a program that takes roll number, percentage of marks and grade from user as input Program should display the formatted output lke following Roll no Input value Percentage @ input value % Grade 2 __input value Tinclide
#inctude
int main() : cirscr(): int roll_number; float percantage: char grade; print(‘Please enter your Roll Number") scanf("%d", Broll_number); print’Please enter your Percenta scanf("%t" &percentage), print("Please enter your Grade’ "); scanf(" %c", &grade); I! All use SPACE before %oc like " %o" net lke " %e "); print("Roll no \t\t:it\t %d \n"roll_number); printf("Percentage \t\tit %f "percentage; prinif((Grade itt: \t Wt %e",grade}, getchy, 1 Output Please enter your RollNumber: 36 Please enter your Percentage : 89 Please enter your Grade : OA Roll no 36 Percentage : 8.000000 Grade LAActivity 24 Write a program that takes as input the length of one side of a squere and calculates the area of squere. Finclude=eidio > finclude
int maint) ‘ clrser(), int n; printf(’Enter any number: ") scant("%6d" Bi print((\nArea of Square =%d",n"n); getch(); return 0; getch(); } Output Enter any number: 6 Area of Square= 36 Activity 2.5 Write 2 program thet takes as input the number of balls in jar A and the ndmbers of balls injar 8. ‘The program caloulates and displays the total number of balls #include
#include
int main() { printf("Enter number of balls in Jar"); scen(("%d",fa); printf("Entor number of balls in Jar B:* scanf(‘%d", 8b); sum=etb, print(‘Total Number of Balls = Sed',sum): getchd: return 0; } ‘Output Enter number of balis in Jar A 10 Enter number of balls in Jar B: 15, Total Number of Balls = 25[Retivity 26 White a program that takes onginal price of a shirt and discount percentage from user Program should display the original price of shirt discount on price and price after discount Finclude
#inctudeeconio,h> int main) { irser(); Int op. 0p; print("Enter Orignal Price of shirt"); scant("Yed", 0p), Print("Enter Discount in percentage’); scanf("%d' &dp); print{("aOrignal Price of shirt= %d"\op); Print("nDiscount on Shirt = %d" dp*op/t00); print((\nPrice of shirt after discount = %d".op-dp} getcn(), retum 0; } Output Enter Original Price of shirt 280 Enter Discount in percentage 10 Original Prise of shirt= 290 Discount on Shirt= 29 Price of shir after discounts 261 Activity 2.7 Write 2 program that takes 2 digit number from user, computes the product of both digits and show the output #include
‘#include
int main() ( cltsor(| int dight, digit2; printi(’Please enter the first digit number: "); scani('%d Bagi), print("Please enter the second digit number") scanf("%d", igit2); printf(“nProduct of first and second digit is: ed", digit digit2); getch(); } ‘Output Please enter the first digit number: 6 Please enter the second digit number: § Product of fist and second digit is: 30Activity 21 Write a program that takes seconds as input and calculates equivalent number of hours, minutes and seconds, Findude
finclude
tat main { ceirser(); float seconds, minutes, hours, print" Please enter the second: seant(" %f", &seconds), minutes = seconds / 60; hours = minutes / 60, print("nTotal Seconds: % 2! \nTotal Minutes: %.2finTotal Hours: %.21",seconds, minutes hours)| getch(); . ) Output Please enier the seconds: 224 Total Seconds: 234.00 Total Minutes: 3.90 Total Hours: 0.07. Activity 2.9 Convert the following algebraic expressions inta C expressions, x= 6y+x x= yz? + 3y 2 zexe 3x z= (x-2)'+3y x ae a(x +32 )+2 +4 ya [nod oot tytz sztztz43ty tytyl atx 2=(K-2) * (x2) +3" YE(x# 32/2) 4z%z0zex/zRetivity 240 Consider the variables x=: 7. Find out the Boolean result of folowing expressions, Q+5)ry (+4) == oy xls (y-4) /2)>= x asx (73) <= 20 Solution: (2+5)>y False (xtra) =e y. True x= {y-4) False (y/2)F=x Tue asx True (x79) <#20 True Rellvily 247 Assume the following variable values x=4, y=7, 2=8. Find out the resultant expression, b&z<5 88 {(true) fz>x) x=s2||ys=8 False 7>=y8R2<5 True 2225 |)x
x) False Activity 2.42 Find out the result of the following Expressions: 161(5 +3) 743" (1242) 25%374 24-9°21(373) 18 /(15-3*2) Solution: 18/(5 +3) =2 7+35(12+2) = 49 25%3"4 24 34-9°2/(3"3) =32 18/(15-3"2) =2ka MCs A 8 c dD Bo wnsnlb a device that fakes 1 1 | data ag input, procass that dats | Computer| Printer | Mobile | Allof these | and generates the output. | [Tach programming language Ras ieacee | 12 its. or ..furetions for UO | Keywords | SiN Language | both andb |_| operations. iy [>| € tanguage offers printf function > | pacuaiis Program | Input output | Alor these Ty [nse funstion Te used To gat 5 | lissuntomuser go'ch scant printt print t é The ee ‘escape | ‘unprinted “printed “print letter sequence"| formatted’ | sequence’ | formatted The format specifier % f show | ‘lua int float char | Allof these “The format specifier 9 Cshow 7 nessa ace int float char Grouped Wien we use Sef to daplaya | 8 | fost value, it display ... digits 5 6 7 8 after the decimal point | Scanfis © builtin function nC 1 | 9 | language that takes....... from | Input | Output | Instruction | Guideline |__| user into the variables The expected input data type it 410 | scantfunction can bespecifed | scant | ose ee | ee with the help of | = * i an | Toma ptsotseanrtineten | |g 5 5 The frst part of ecanffunction | Siete | Inside the 7 isemne | Inside the 2 single | double tiple is curly bracket quotes | quotes quotes Wihout & sign mh scant function, 13 | theprogramgets........ but | Instruction | Compied | Executed | Input does not behave as expected | “The common mistake in scant | : 14 | tunction sign. £ s 4 Tunelion is used to read 6 |S aees prntt | getcn) | scant scanTo use getehd function, Here is 46 | a1need toinclude the ibrary stdion | voidmain) | con. | include.h in the header section of program, | When we read character through |p... | 17 | scant,itrequres.usto.....for | PSF | pressesc | Pressshit | Pressctl further execution. i—Ta is ideriher Tor 1 Format | Escape | Statement | Logical 18 | compier which iaent a | 18 | Sompler wnicn entnes snd 02 | oeciter | sequence | terminator | operator [4p | hc tenguage Je used i Fe as statement terminator. | ' ‘are used in pint Siatoment Escape. Format | 2° | function inside the “and. Terminator | terminator | terminator | specifier pintie My name fe VAR, : Escape | Format 4 i th v rf 2 " the above statement \" is sequence specifier Format Operator > consist of two Formal Escape ‘Statement 2 | characters specifier | sequence | terminator | Al's! ese Whats the purpose of escape | Display | Generates | penioyes | Display B sequence \\? Bak ‘arrstert previous char Single yes |. stash ‘sound Quote Dispiay 24 | What is the purpose of escay Sime | Removes | Generates an| Display sequence \a? ‘Gus: previous char | alert sound Back siash | | After escape character 25 | specifies novement of the } oo. w » a cursor to start ofthe next ine. Which escape sequence is used 26 | to print the output on multiple \ » te wu lines? Escape sequence_ specifier the I/O function of 27 | roving to the next tab stop | im x x % horizontally I The list of some basic operator ‘Assignment | Arithmetic: Relational: 28) yoesis ‘operator | operator ‘operator | All ofthese: Ts used 0 assign a 29 | v2lue a variable, orassign a | Aithmetc | Assignment | Logical | Relation value of variable to another operator | operator | operator | operator variable,is used as assignment 3° | operator in. = Z ! * py | ate usedto perform Trittmmatic | Assignment | Logical | Relational | aritimetic operations on data__| operator | operator _| operator _| operator a2 | Whatis the name of/ operator? |Ahutioieaton] ‘Subtraction | Division | Addition opersior | operator | operator | operator sa ries he vais ote Division | Mutipication | Addin | Modulus 33 | operand by the value of right — |e sat - operand op pet op oper ifbotn the operands are oftiype 34 | int then result of division is also | char ver int Allof these | type of Jp abinaly operator — Logical | Arthmetic | Mutipscetion | Division 35 | which performs the product of a hase ball operator | operator ‘operator | operator lise: calculales the sum of two | Arithmetic | Muliplication Division Logical operands. operator | operator | operator | operator ‘The stateronta- of —a, Used 37 | todecrease the value of 2 by 1 18 18 4 | ge | — subracts ight operand from | Aitnmatic | idtipicaton | Divsion | Subtraction the leh operand operstor | operator _| operator _| Operator go | Whatisthe name of% operator |Nulipiesion| Modulus | Division | Subtraction operator | operator | operator | Operator forms divisions of et gq | perand by the right operand] Medulis | Division | Subtraction | Athmatic and retums the remainder value | operator | operator | Operator | operator ater division compare hwo values to ; 41 | determine the relationship | ee | ae | between values. re = ee C language allows us to perform 42 | relational operators on int Numeric char | Bohbande | and__data type. TAtrue value of relational 43 | operator is represented ° 1 z 3 by, 7 ‘false value rlainal operator |, 7 > > al represented by __.a ‘Tn C language, ——— ‘Assigrment | Arithmetic | Logical | Relational operator is used to check for Daiphaaeaat operator | operator | operator | operator __Sperator assigns the result 46 | of expression on right side to the = . % variable on left side | perform operations on Boclean expression and produce | Logical | Assignment | Aritimetic | Relational 47 a Boolean expression as a operator | operator | operator | operalor ‘result Which one from the folowing I= 48 | nota logical operator? Ge ee lie aoe ‘operator takes two) Bociean expressions as 49 | operands and produces the AND: oR NANO NOT resuit rue if both of its operands are true accepts Boolean 50 | expression and retums true fat | AND oR NANO NOT least one of the operands is true. —______speraiar negates or 154 | everses the value of Boolean aa Ai eR finite expression, It makes it true, iit is false and false if tis true. a require two operands to | Relatonal| —_Unary Binary Togical perform the operation. operator | operator | Operator | Operator A plied over one | Unery | Binary Logical | Relational ‘operand only operator | Operator _| Operator_| operator Which operalor has high » 54 | crecadence? # 0 ! "___opevaior are applied on | Fa rant Temary | unary Brnary Logical function is used to clear the 56 | output screen of C language getch scant print lrscr); editor.7 =z]. + 6 e z e o 10 a a; ¢ 8 D B € 8 A e 7 SC) az B c x 5 c a c B e Ez] 22 23 24 25 26 27 28 29 30 Al 8B A c B D c D B a Ed 32 33 4 a5 36 7 38 40 A c A c c A A D A 4a 42 43 Aa a5 46 aT 48 _ 50 B D 8 A A B A c 8 51 52 53 54 55 [A c A c A Re elstme ste 4. Define a computer. ‘Ans. A computer is a device that takes data as input, process that data and generates the output 2. Define printf function? ‘Ans. printf is @ builtin function in C programming language to show output on screen. Its name comes from “print formatted” that is used to print the formatted output on screen, All data types can be displayed with printf functon, 2 3. What Is format specifior? Ans. Format specifiers are used to specify format of data type during input end output operations. Format specifier is always preceded by a percentage (%) sign 4, Write down the format specifiers against different data types in C language. Ans. Format specifiers against different data types in C language are as follows: Data type Format Specifior int % dari Toat %t char %e5. Iffloat hela! int age = 35; What will be tho output of following statement: printi("My age is %d and my height is %. 2f", age, heigh Ans. Output: My ago is 35 and my height is 6.80 6, What will be the output of following code: #include
void main() { printt("‘Sum of 23 and 45 is %d", 23 + 45); ? Ans. Output Sum of 23 and 45 is 68 7. What is the purpose of scanf()? ‘Ans. scanf is 2 builtin function in C language that takes input from user into the variables. We specify the expected input data type in scanf function with the help of format specifier If user enters integer data type, format specifier mentioned in scanf must be %d oF %i, 8. What is common mistako in scanf function? ‘Ans. It is @ very common mistake to forget & sign in the scanf function Without & sign, the program gets executed but does not behaye as expected. 9. What is the use of getch()? Ans. getch() function is used to read a character from user. The character entered by user does no} gat displayed on screen, This function is generally used to hold the execution of program because the program does not continue further untii the user types a key. 10. Which library function is used to include getch()? ‘Ans: To use this function, we need to include the library conio.h in the header section of program. 14. What Is statement terminator? Ans. A statement terminator is identifier for compiler which identifies end of a line. In C language semi colon (;) '$ used as statement terminator. if we do not end each statement with a: it results into error, 42. What Is the purpose of escape sequence in C language? ‘Ans. Escape sequence are used in printf function inside the double quotes (° change its normal behaviour of showing output. It force printt to 43, What is Formation of escape sequence? Ans. Escape sequence consists of two characters. The first character is always back slash (\) and the second character varies according to the functionality that we want to achieve. Back slash (\) is called escape character which is associated with each escape sequence to notify about escape, 14, What Is the purpose of In? Ans. After escape character, \n specifies movement of the cursor to start of the next line. This escape sequence is used to print the output on multiple lines,15, What is the purpose of Tab (\t)? ‘Ans. Escape sequence it specifies the V/O function of moving to the next tab stop horizontally. A tab stop Is collection of 8 spaces. Using \t takes cursor to the next tab stop. This escape sequence is used when user presents data with mare spaces 16. What is an operator? [Ans. An operator in a programming language is 2 symboi that tells the compiler or interpreter to perform specific mathematical, relational or logical operation and produce final result. 17. Write down the name of basic operator? Ans: C language offers numerous operators to manipulate and process cata. Following is the list of some basic operator types: + Assignment operator + Arithmetic operator + Logical operator + Relational operator 48, What is assignment operator? Ans. Assignment operator is used to assign a value to a variable, or assign a value of variable to another variable. Equal sign (=) is used as assignment operator in C. 19. Write a program that swaps tho vatues of two integer variables. Ans. Hinclude
#inciudeeconio.h> void main() ‘ clrscr), inta 2, b=3, temp; temp= 3; a=b; b= temp; printf("Value of a after swapping: %c\n", a); print{("Value of b after swapping: %¢\n:, b); ; getch(); 20. What Is the use of an arithmetic operator? ‘Ans. Arithmetic Operators are used to perform arithmetic operations on data 24, What Is Division operator? ‘Ans. Division operator (/) divides the value of left operand by the value of right cperand. 2g. Float result = 3.0/2. After the statement, the variable result contains the value 1.5, 22, What is Multiplication operator? Ans. Muliiplication operator (") is @ binary operator which performs the product of two numbers. eg. int multiply = 5° §; After the execution of statement, the variable muttiply contains value 25.23, What Is an Addition operator? Ans. Addition operator (+) calculates the sum of two operands. eg. intadd = 10 +10; Resultant valve in variable add is 20. 24. Why the statement a= a +1; and a—; are used in C language? Ans. The statement a = a + 1; is used to increase the value of variable a by 1. In C language, this ‘statement can also be written as a++; or ++3; similarly, a--or- used to decrease the value of aby1 25. What is Subtraction operator? Ans. Subtraction operator (-) subtracts right operand from the laft operand. eg. intresu = 20-1! ‘After performing subtraction, value 5 is assigned to the variable result 26. What Is Modulus operator? ‘Ans. Modulus operator (%) perfarms divisions of left operand by the right operand and returns the remainder value after division. Modulus operator works on integer data types. int remaining = 14% 3; ‘As, when we divide 14 by 3, we get a remainder of 2, so the value stored in variable remaining is 2 27. What is common mistake while writing arithmetic statement is C language? ‘Ans. While writiig arithmetic statement is C language. a common mistake is to follow the usual algebraic rules e.g. writing 6 * y as 6y, and writing x * x * x as x’ etc, It results in a compiler error. 28. Why relational operators are used in C language? ‘Ans. Relalional operators compare two values to determine tha relationship between values Relational operators identify either the values are equal, not equal, greater than or jess than one ‘another. C language allows us to perform relaticnal operators on numeric and char type data 29. What Is difference between Assignment operator and equal to operator? Ans. In C language, equal to operator is used to check for equality of two expressions, whereas: ‘assignment operator assigns the result of expression on right side to the variable on left side. Double equal operator (==) checks whether right and left operands are equal or not. Single equal ‘operator (=) assigns right operand to the variable on left side. 30. What Is difference between logical operator and arithmotle operator? Ans. Logical operator Arithmetic Operator Logical operators perform operalins on] Arithmetic Cperators are used to perform Boolean expression and produce a Boolean | arithmetic operations on data, Division expression as a result. The result of a | operator, multiplication operator and modulus ‘elalional operation is a Beolean expression, | eperater is some arithmetic operater. so logical operators can be performed to evaluate more than one relational expression. it31, What Is difference between Division operator and Multiplication operator? Ans. Division Operator Wullipiication Operator Division operator (/) divides the value of left ‘operand by the value of right operand. Example Float result = 3.0/2.0; ‘Multiplication operator (*) is a binary operator which performs the product of two numbers, Example: ‘int multiply = 5° 5; 32. Define logical operator? Ans. Logical operators perform operations on Boolean expression and pioduce a Boolean expression as @ result. The result of a relational operation is a Boolean expression, so logical operators can be performed to evaluate more than one relational expression. 33. Write down the name of logical operator. Ans. The logical operators are as follows: _ Operator Description Eg Logical AND il Logical OR - 1 Logical NOT ‘34, What is AND operator (&&)? Also write its truth table, ‘Ans. AND operator &8 takes two Soolean expressions as operands and produces the result tue if both ofits operands are true. It returns false if any of the operands is false. The truth table for AND operator is shown below: Expression 4 Operator Result False ah False False ah False True ae False True 8h True 35. What Is OR operator (1)? ‘Ans. OR operator accepts Boolean expression and 36. Draw the truth table for OR operator. An The truth table for OR operator is shown below: retums true if at least one of the operands is tue, Expression 1 | Operator | Expression? Result False a False False False i Thue Troe True I False True True IL True True37. What is NOT operator (})? Also draw truth table ‘Ans. NOT operator negates or reverses the value of Boolean expression. It makes it true, if itis false and faise if itis true, The truth table for Not operator is given below: Expression Operator Result Troe r Fal False T Tue 38. Differentiate between Unary and Binary Operators, Ans. Unary Operator Binary Operator Unaty operators are applied over one operand ‘only &g. logical not (!) operator has only one. ‘operand. Sign operator (-) is another example Binary operators require two operands to perform the operation e.g. all the arithmetic ‘operators, and relational operators are binary of a unary operator e.g. -5 operators. The logical operators 88 and || are also binary operators. 39. What is Operators’ Precedence? Ans. |f there are multiple operators in an expression, the question arises that which operator is evaluated first. To solve this issue, precedence has been given to each operator. An operator with higher precedence is evaluated before the operator with lower precedence In case of equal precedence, the operator at left side is evaluated before the operator at right side. 40. Describe the operator precedence of different operators? Ans: Operator Precedence () 1 “1% @| | lo) of af els) | 44, Define Ternary operator? ‘Ans: The operator offers three operands in C programming Language is called temary operator.42. Differentiate between scanf and getchi)? Ans: ([weant gotehy) aeanf is a builtin funclon in © language that takee Input from user into the variables. Wa specify the expected input data type in scant function with the help of format specifier. if user enters integer data type, format specifier mentioned in scant must be %d or Sei. ‘geich() function is used to read a characier from user. The character entered by user does rot get displayed on screen. This function is generally used to hold the execution of program because the program does not continue further untl the user types a key. To use this function, we need to include the library conio.h in the header saction of program. 43. What Is the difference betwean == operator and = operator? Ans: In C language, == operator is used to check for equality of two expressions, where as = operator assigns the result of expression on right side to the variable on left side, Double equal operator ‘assigns right operand to the variable on left side. 44, Write use of clrscr()? checks whether right and left operands are equal or not. Single equal operator (=) Ans: This function is used to clear the output screen of C fanguage editor Syntax: cirser(),
You might also like
Computer 12 CH10 Notes
PDF
No ratings yet
Computer 12 CH10 Notes
11 pages
Chapter 4 Part 1: Input and Output
PDF
No ratings yet
Chapter 4 Part 1: Input and Output
49 pages
Introduction To Programming Using C Language Lesson - 1 Output - Input Functions
PDF
No ratings yet
Introduction To Programming Using C Language Lesson - 1 Output - Input Functions
265 pages
CS 111 Introduction To Computer Science: by Wessam El-Behaidy & Amr S. Ghoneim
PDF
No ratings yet
CS 111 Introduction To Computer Science: by Wessam El-Behaidy & Amr S. Ghoneim
31 pages
Unit 1
PDF
No ratings yet
Unit 1
118 pages
Chapter-3-Computer Science-10 Class-Federal Board
PDF
67% (6)
Chapter-3-Computer Science-10 Class-Federal Board
24 pages
Managing Input Outout Function
PDF
No ratings yet
Managing Input Outout Function
23 pages
Lecture10!10!11266 - Formatted and Unformatted Input Output Functions
PDF
No ratings yet
Lecture10!10!11266 - Formatted and Unformatted Input Output Functions
31 pages
Lab Manual Latest
PDF
No ratings yet
Lab Manual Latest
72 pages
10th Comp CH 2 LQ
PDF
No ratings yet
10th Comp CH 2 LQ
20 pages
CO110 Computer Programming5
PDF
No ratings yet
CO110 Computer Programming5
25 pages
C Programing: Applications of C Programming
PDF
No ratings yet
C Programing: Applications of C Programming
13 pages
Computer Programming Chapter2part2
PDF
No ratings yet
Computer Programming Chapter2part2
41 pages
Managing Input and Output Operation
PDF
100% (1)
Managing Input and Output Operation
35 pages
Input and Output PDF
PDF
No ratings yet
Input and Output PDF
20 pages
Introduction To Input Output in C Programming-1
PDF
No ratings yet
Introduction To Input Output in C Programming-1
36 pages
Sololearn C
PDF
No ratings yet
Sololearn C
55 pages
4.input Output Operations
PDF
No ratings yet
4.input Output Operations
18 pages
The Basic C Structure
PDF
No ratings yet
The Basic C Structure
3 pages
Basics C
PDF
No ratings yet
Basics C
31 pages
Escape Sequence Effect: CSE115L - Programming Language I Lab Lab 02 Basic I/O and Data Types I
PDF
No ratings yet
Escape Sequence Effect: CSE115L - Programming Language I Lab Lab 02 Basic I/O and Data Types I
2 pages
E 102 F 23 Lecture 003 A
PDF
100% (1)
E 102 F 23 Lecture 003 A
27 pages
Day 2 - (Managing IO and Operators)
PDF
No ratings yet
Day 2 - (Managing IO and Operators)
25 pages
C Programming 1
PDF
No ratings yet
C Programming 1
29 pages
Module 1 C Programming JDecisionMakingStructureArrays
PDF
No ratings yet
Module 1 C Programming JDecisionMakingStructureArrays
35 pages
C Programming - Managing Input and Output Operations
PDF
0% (1)
C Programming - Managing Input and Output Operations
8 pages
Turbo C Lecture
PDF
No ratings yet
Turbo C Lecture
14 pages
CSC 216
PDF
100% (1)
CSC 216
14 pages
Unit 3
PDF
No ratings yet
Unit 3
16 pages
Gyne & Obs History Outline
PDF
No ratings yet
Gyne & Obs History Outline
3 pages
10th Class Com Science Notes 2024 CH 2
PDF
No ratings yet
10th Class Com Science Notes 2024 CH 2
39 pages
OUTPUT Statements
PDF
No ratings yet
OUTPUT Statements
4 pages
ECE128 - LAB Assignment Chapter 1
PDF
No ratings yet
ECE128 - LAB Assignment Chapter 1
26 pages
C Tutorial Day 5
PDF
No ratings yet
C Tutorial Day 5
10 pages
Exercise 5
PDF
No ratings yet
Exercise 5
4 pages
The Basic C Structure
PDF
No ratings yet
The Basic C Structure
8 pages
12th Computer Chaptr 10
PDF
No ratings yet
12th Computer Chaptr 10
25 pages
C Programming For Jhatu
PDF
No ratings yet
C Programming For Jhatu
29 pages
Module 3 & 4 - 231012 - 171457
PDF
No ratings yet
Module 3 & 4 - 231012 - 171457
42 pages
Chapter 2 LQ
PDF
No ratings yet
Chapter 2 LQ
4 pages
C Unit2 Notes
PDF
No ratings yet
C Unit2 Notes
32 pages
I/O Functions
PDF
No ratings yet
I/O Functions
16 pages
12th Computer CHP 10
PDF
No ratings yet
12th Computer CHP 10
3 pages
Fundamentals of C
PDF
No ratings yet
Fundamentals of C
58 pages
C Programing
PDF
No ratings yet
C Programing
101 pages
Unit - 3 (C-Programming)
PDF
No ratings yet
Unit - 3 (C-Programming)
17 pages
C Input Output
PDF
No ratings yet
C Input Output
6 pages
CHP - 3 - Console Input Output
PDF
No ratings yet
CHP - 3 - Console Input Output
28 pages
Variable Naming in C
PDF
No ratings yet
Variable Naming in C
22 pages
02 Chapter 2 (31-69)
PDF
No ratings yet
02 Chapter 2 (31-69)
39 pages
Introduction To C
PDF
No ratings yet
Introduction To C
20 pages
Unit 2
PDF
No ratings yet
Unit 2
110 pages
Statements and Input Output Statements
PDF
No ratings yet
Statements and Input Output Statements
70 pages
Ivth Unit - Files in C
PDF
No ratings yet
Ivth Unit - Files in C
19 pages
Types of Output and Input Functions in C
PDF
No ratings yet
Types of Output and Input Functions in C
5 pages
PST Unit-2 After Variables gWofFW
PDF
No ratings yet
PST Unit-2 After Variables gWofFW
13 pages