0% found this document useful (0 votes)
6 views6 pages

Ip 2marks

The document provides an overview of fundamental programming concepts in C, including algorithms, data types, variables, operators, and control structures. It covers topics such as type casting, constants, keywords, loops, functions, pointers, and file handling. Additionally, it explains the differences between various programming constructs and provides examples of code for practical understanding.
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
0% found this document useful (0 votes)
6 views6 pages

Ip 2marks

The document provides an overview of fundamental programming concepts in C, including algorithms, data types, variables, operators, and control structures. It covers topics such as type casting, constants, keywords, loops, functions, pointers, and file handling. Additionally, it explains the differences between various programming constructs and provides examples of code for practical understanding.
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
You are on page 1/ 6
WE | roduction to Progr ammi 2 Marks Ques Ing Unit ine Algorithm and its properties, thm isa step-by-step procedure f tasks Is properties Incleae specitications, See Hoe, wel calculations, di Ns, data proces defined, etfective, and 3. _ Define Data ty ype and, A data type in programmin, character, and string. In C, ‘mention different types of Data types. 1 defines the tyne of data a variable can hold, suchas integer, lat Primary data types include int, float, double, and char. , . 4 Define Variable and its properties variable isa stor i Avalos Prats Jatin pared with an associated symbolic name, which contain some known wn quantity of information referred to as avalue tsp orurkrown erred to 2s a value. ls properties include a datatype, name, 5. What is operator and operand in C. ‘An operator in Cis a symbol that tells the compiler to perform specitic mathematical of logical ‘manipulations. Operands are the entities on which operators perform these manipulations, 6. What is type casting? Where we need to use this? ‘Type casting is the conversion of a variable from one data type to another. Its used when operations involve different data types to ensure correct computation or to avoid type errors, 7. Explain various types of constants. Constants are fixed values that do not change during program execution. Types include integer constants, floating-point constants, character constants, and string literals. 8. Define keyword. Mention some keywords. Keywords are reserved words in a programming language that have a predefined meaning to the compiler. Examples in C include int, return, if, else, and while. 9. What isa string constant? Astring constant, also known as a string literal, is a sequence of characters enclosed in double ‘quotation marks, like "Hello, World!" 10. What is conditional operator? ‘The conditional operator is ternary operator (taking three operands) in C, written as ?:, which works ite anielse statement compact fom ’ .. What is top-down and bottom-up approach? 22. hat op dow te igs evel of conceptual design nd breaks it down ot tats Top-down approngy sa te tes and combines hem torn hehe lev anctonaies ; complexity? ie complet a ro gua on gor 2,25 ncn ofthe nao ure ofthe time taken by an r sg measure of the amount of memory space an algorithm needs 12, What Time complexity is a meas the input. Space complexity is 2 terms of the input size @ scanned with OKEN Scanner jedence snd an operator PFE 13, Whats expression? Anon NT tant a nik 2 oan non na tsaeenaed m a ere Oper tor precedence detines theo yacter set of C language? ne alphabets, digits, special characters, and symbols that rat c language includes all rnd process. includes ASCH characters 14, Define cha The characters the language can ¢e¢28" identifiers in C? like variables, functions, arrays, etc. Rules include starting or underscores, and being case-sensitive. an identifier and rules for nto entities followed by letters, digits, 45, Whats anidentifier isa name give fat a fetter or underscore, 46. What are the logical operators in C tal operators in C include && (logical AND), or invert boolean expressions. [1 oeical OR}, and | (logical NOT), used to combine 17. What isa token in C language with example? ae oenmthe smallest element of 2 program that is mearingfl to the comple, €xamples include Terwords, entifies constants string iterals, and symbols ie 6° / tor? Give example 18, What is a unary operat that takes @ single operand t ‘Avnary operator is an operator t negation operator - (for negating 2 valve, 10 operate on, Examples include the 419, What are features of C Language? Features of C language include simplicity, allows low-level memory manipulation. efciency, flexibility, portability, and modularity. Iaiso int() and scanf() functions. 1 for output, to display text and: fatted input from the Keyboard 20. Specify the use of pr The printf) function is use used for input, to read form: variables to the screen, while scant) is Unit -2 1, Specify the syntax used for for statement. The syntax fora for statement 5 for(ntiaization; condition increment/decrement) (/* code to be executed */) nue statements. tie skips the rest of the lap's current tration and 2. _ Difference between break and conti peak exits the loop immediately, while con proceeds with the next one false */) 3. Give the syntax of ihelse statement. The syntax yarmion){ /* code condition is true /} else (/ code fcondton 5 1p and exit controlled loop? ion before entering the dition after the loop hi Joop {ike for and while loops), 4. Whats entry controlled loor ia enecuted at least once (ike do [An entry-controled loop checks the consi (while an ext-controlied loop checks the con® while loop) ‘5, Whatisa looping? cpngs the proces by which a set of instructions is executed rePE3te0Y until a certain condition is ‘and inerement ++ and decrement ~ operators. ' + @ scanned with OKEN Scanner 6. _ilference between while and do-while loop in C2 ‘use oop is entey-contcoled, meaning it tests the condition before each iteration, whereas a do ‘thie loops exit-controled, testing the condition after each iteration 7. Difference between simple if and if-else? ‘A simple if statement executes code only if a condition is true; an if-else statement provides code to ‘execute if the condition is false as well, 8. What isnested loop? ‘Anested loop is a loop inside another loop, where the inner loop completes all its iterations for each iteration of the outer loop. 9. What is iterative statement and types in C? erative statements or loops enable repeated execution ofa block of code, with types including for, while, and do-while. 10. What is elseif ladder? ‘An else if ladder isa series of if statements where each subsequent condition is checked if all previous conditions are false. 11, What is go to statement? goto is ajump statement in C that transfers control to the labeled statement, yer t's often discouraged due to potential for confusing contro! flow. 12, What is the purpose of exit(0) statement? ‘ext(0) terminates a program successfully returning control tothe operating system. 13, What is switch() statement. ‘A switch statement allows a variable to be tested for equi value is called a case ality against alist of values, where each 14. Write a program to display whether a given number is even or odd. frinclude {nt main() { Int pum, printi("Enter an integer seanf("%d", Snum) flour S62 == 0) print(("%d is even, num); else print{("%d is odd.*, num) return 0 15. Write a program to display whether a given year Is leap year oF not include int mand) ( sot year printi("Enter a year") scant(-Sd", Sean: iiiyear S 4 == 0 8S year % 200 != 0) || year % 400 rintt("Xd is 2 leap year", year: @ scanned with OKEN Scanner printt("%d ts not a leap year.", year); return ) ynit=3 2) What isan array? 2 anon is a calectin of elements ofthe same type, stored in contiguous memory locations 2. Differentiate between actual parameters and formal parameters. etuat parameters are the arguments passed to a function, while formal parameters are inthe function definition that recelve the actual parameters, the variables 3. What is the significance of return statement? 3 return statement terminates the function, optionally passing a value back othe function caller. Why is it necessary to give the size of an array Inan array declaration. Size ofan artay is needed to allocate the correct amount of contiguous memory forthe 72 elements. ‘What are multidimensional arrays? ‘Multidimensional arrays are arrays of arrays, lke a with two or more indices to access the elements, matrix s © Define user defined function user-defined function isa block o ‘making the code reusable and modular, J code created by the programmer to perform a speciic task a 17 dine recursive function and write one example 7 mie function function that cal tsel to sole 9 smaller instance of the same problem. xample: a function to compute factorial Ant factoriafint 9) { Mines) return 1; cbse return nt factonal{n - 1); \ a “ 8 waite storage classes in s Te ae a ave auto, este, sa, dete These determine Ie itetime, vil, we andstorage locaton of avaiable 9 What is function? Atunction « a block of code that pert low reuse. Functions can lacceot parameters and retun a value forms a specific task, encapsulated to al 10. Ditferentiate user defined and library functions to. Gated functions are weten by the programmer {0 Pero speofic tasks, whereas HBFaTY ayn are pre-defined and included iC standard iPrvie such as peit(() nd scant) rnction’s name, return type, and 11, What is function prototype? ithe function's interface 1 wi pototype isa declaration ofa function that species We fur aameters thou inching the body Fnforms the commer about atime, while an arrays 2 collection @& ine difference between 2 variable and an array le through an index wove wa single data storage location that holds one veabies,alof the same type, stored contiguous in x value at remary, access oe @ scanned with OKEN Scanner stems. 4 Unit ) what isa Pointer and explain with an example? pointer» vanable tha stores the memory address of another pp Svar Here, Bis a;ointer to int that holds the address of van: Exa™Bleint “pnt vors10, @B__ Whats function pointer? ‘Aiunction pointer is a pointer that points to a function r invoke ation recy snd ition rather than a data value. It can be used to 85 functions as arguments to other functions SCD_ Deine string with example? ‘string in Cis an array of characters ter 'ated by a null character \0. Example: char stl) “Hello”, © wratisthe ference between scanf() & gets)? scanf() reads formatted input from omstdn, soppingat whtespace, wile gets reads sting rom stdin until a newline character is found, ml aie "ve string handling functions in C are strcpy(), strat), stlen(),stremp(), and strchr() What is the use of preprocessor directives? "eprocessor directives are instructions to the compiler for pre-processing the source code before Compilation They include file inclusion, macro definitions, and conditional compilation, What is pointer to pointer? ‘painter to pointer is a farm of multiple indirection or a chain of pointers. Normally, a pointer contains the address of a variable. When we define a pointer to a pointer, the first painter contains the address of the second pointer, which points to the location that contains the actual value. Unit - 5 1, What is enumerated data type? Give an example. ‘An enumerated data type (enum) i a user-defined data type in C that consists of integral constants Example: enum color { red, green, blue }; 2. What command line arguments? Command line arguements are parameters supplied to the program when itis invoked, accessible within the program through the variables arge (argument count) and argy (argument vector), J) Define Structure and Union? a user-defined data type that allows to combine data items of different kinds. A ' >) wwte ne Advantages ot tetres . C ron closers de better data management, ease of use for complex data handling, GKanrages of structures inchs and the abiity to represent real-world entities more effectively. 5. Define a file? A file i a container in 2¢ ted using a stream of data computer system for storing information, which can be accessed and ‘of allocating memory during runtime using functions like What is dynamic memory allocation’ ® yn is the process @ scanned with OKEN Scanner 7. Define bit field Abit field is a way to ify the ‘ay to pack data into a smaller storage space. It is used in structures to specify eatin a smaller storage space. It is use’ 8. Whatis the purpose of ft is the purpose of fseek( used to move the file point: 10. What are the modes used The modes used in fopen() are re), ‘and read), "a+" (append and read), and their binary count 11. Whi frea is the purpose of fread() and fwrit used to read a block of data from a ()is used to write a block of data toa file. 12. Write the differences between text file and binary files Text files contain data that is human-readable like plain text, while binary files contain data in a format that is not human-readable, intended for com 13. What is the purpose of fclos fcloseall() is used to close all open files that have been opened with foper 6 write difference between an array and a structure. Avarray's a collection of elements of the same type, accessed by index, whereas a structure isa collection of elements potentially of different types, accessed by name @ scanned with OKEN Scanner

You might also like