0% found this document useful (0 votes)
53 views14 pages

Important Questions in CF&P-1

The document discusses different types of questions that could be asked related to computer hardware and software topics. It provides examples of questions about differentiating between hardware and software, computer components and architecture, data storage types, programming languages, and more. Various concepts related to variables in C programming are also defined, including data types, naming rules, scope, lifetime, and examples.

Uploaded by

VINAY KUMAR
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
53 views14 pages

Important Questions in CF&P-1

The document discusses different types of questions that could be asked related to computer hardware and software topics. It provides examples of questions about differentiating between hardware and software, computer components and architecture, data storage types, programming languages, and more. Various concepts related to variables in C programming are also defined, including data types, naming rules, scope, lifetime, and examples.

Uploaded by

VINAY KUMAR
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 14

Important questions UNIT 1

1. Differentiate Hardware and software. Write types of software.


OR

Differentiate Application Software and System Software.

2. Draw architecture of Computer


OR

What do you mean by Components of Computer.Explian with diagram?

3. Differentiate Complier and Interpreter and assembler.


OR

Explain High level Language, Low Level Languge, Assembly Level Language.

4. Convert the following

(i) (1056)16 = (?)8 = (?)2

(ii) (5CS)16=(?)10 = (?)8

(iii) (10111)2= (?)10= (?)8

(iv) (74524)8= (?)2 = (?)10

5. Subtract 11012 and 10102.

6. Differtiate Primary memory and Secondary Memory.


OR
Explain ROM,EPROM,PROM,EEPROM,Static RAM,and Dynamic RAM.
Important questions UNIT 2

1. Write various operators in C with Example.


2. What is data type in C?
OR
What is litterls.
3. Explain printf( ) and Scanf( ) in C.
OR

Write formatted input output function.

4. Differentiate Source Code and object Code.

1. Source Code:
Source code refers to high level code or assembly code which is generated by
human/programmer. Source code is easy to read and modify. It is written by programmer
by using any High Level Language or Intermediate language which is human-readable.
Source code contains comments that programmer puts for better understanding.

Source code is provided to language translator which converts it into machine


understandable code which is called machine code or object code. Computer can not
understand direct source code, computer understands machine code and executes it. It is
considered as fundamental component of computer. In simple we can say source code is a
set of instructions/commands and statements which is written by a programmer by using
a computer programming language like C, C++, Java, Python, Assembly language etc. So
statements written in any programming language is termed as source code.

2. Object Code:
Object code refers to low level code which is understandable by machine. Object code is
generated from source code after going through compiler or other translator. It is in
executable machine code format. Object code contains a sequence of machine
understandable instructions to which Central Processing Unit understands and executes.

5. Object file contains object code. It is considered as one more of machine code. Some
object file examples are common object file format (COFF), COM files and “.exe” files.
It is the output of a compiler or other translator. We can understand source code but we
can not understand object code as it is not in plain text like source code rather it is in
binary formats.
Difference between Source Code and Object Code :

S.
SOURCE CODE OBJECT CODE
No.
Source code is generated by human or Object code is generated by compiler or other
01.
programmer. translator.
02. Source code is high level code. Object code is low level code.
Source code is written in plain text by using Object code is translated code of source code.
03.
some high level programming language. It is in binary format.
04. Source code is human understandable. Object code is not human understandable.
Source code is not directly understandable by
05. Object code is machine
machine.
It is written in a high-level language like C,
It is written in machine language through
06. C++, Java, Python, etc., or assembly
compiler or assembler or other translator.
language.
07. It can be easily modified. It can not be modified.
It contains comments for better understanding It does not contain comments for
08.
by programmer. understanding by machine.
S.
SOURCE CODE OBJECT CODE
No.
It contains less number of statements than It contains more number of statements than
09.
object code. source code.
10. It is less close. towards machine. It is more close towards machine.
Performance of source code is less than Performance of object code is more than
11. object code as it is less close towards source code as it is more close towards
machine. machine.
Source code is input to compiler or any other Object code is output of compiler or any
12.
translator. other translator.
13. Source code is not system specific. Object code is system specific.

Source code needs to be compiled


or translated by any other
14. It can be changed over time.
translator to get modified object
code.
Language translators like compiler, assembler, interpreter Object code is machine code so it
15.
are used to translate source code to object code. does not require any translation.
The source lines of code gives the readability and
understandability to the user. Use of fewer lines of code This is not the case with object
16.
gives better performance by giving same results in most code.
cases.

6. What do you mean by primitive data types in C, how it differs from derived data types
used in C.?
The data types in C can be classified as follows:

Types Description
Primitive Data Primitive data types are the most basic data types that are used for
Types representing simple values such as integers, float, characters, etc.
User Defined
The user-defined data types are defined by the user himself.
Data Types
The data types that are derived from the primitive or built-in datatypes are
Derived Types
referred to as Derived Data Types.
7. Draw a flowchart to find largest among four numbers.
8. Write short notes on 1)pseduocode 2)Algorithm
9. How to declare idetifers.write scope and lifetime of variable.

What is a Variable in C Programming


A variable is a holder of data. In geek’s terms, a variable is a memory allocation space to a data
type. It stores a value or data so that the C compiler will create a memory space for that data.
Each variable has a separate name to make it readable and unique.

Syntax of Variable in C is:

data_type variable_name = value

Example:

int num = 3

Here,

 int is the data type


 num is a variable name
 3 is the variable value

A Variable in C programming consists of two parts, Variable definition, and initialization.


1. Variable definition = it consists of the data type and the variable name. This part helps
to identify the variable data type and its identifier. Each data type consumes different
memory, so it is necessary to define the variable type.

2. Variable initialization = variable initialization means to provide some value to the


variable as per the data type.

Rules for Variable Names in C Programming

There are rules for defining the variables in C Programming, and those rules are as follows:

 Variable names will always start with an alphabet and underscore. Example: num, name,
a, x, _value.
 Variable names in C will never start with a digit. Example: 4name, is an invalid name.
 Variables should be declared with their data type. Variable names without data type will
generate errors. For example, int a =2 is valid. a = 2 is an invalid variable.
 C is a strongly typed language, you cannot change the data type of a variable after its
definition.
 Reserved keywords cannot be used as a variable name in C programming.
 No white spaces are allowed within the variable name.

What is the Scope and Lifetime of a Variable


The scope is the variable region in which it can be used. Beyond that area, you cannot use a
variable. The local and global are two scopes for C variables. The local scope is limited to the
code or function in which the variable is declared.

Global scope is the entire program. Global variables can be used anywhere throughout the
program.

Lifetime is the life or alive state of a variable in the memory. It is the time for which a variable
can hold its memory. The lifetime of a variable is static and automatic. The static lifetime
variable remains active till the end of the program.

An automatic lifetime variable or global variable activates when they are called else they vanish
when the function executes.
Types of Variables on the Basis of Scope

The variable that is declared in a function or code is called a local variable. The scope of Local
variables is within the defined function only. You cannot use a local variable outside the function
(in which it is declared).

Program of local variables.

#include <stdio.h>

void person()
{
// Local Variables of the function
int age = 20;
float height = 5.6;

printf("age is %d \n", age);


printf("height is %f", height);
}

int main()
{
person();
return 0;
}
Copy code

OUTPUT

age is 20
height is 5.600000

Global Variables

The scope of the global variable is the entire program. They are not defined inside any function
and can be used in any function.

Program to use a global variable in C

#include <stdio.h>

// Declaring global variable


int a = 23;

void function1()
{
// Function using global variable a
printf("The number is %d \n", a);
}
void function2()
{
// Function using global variable a
printf("The number is %d \n", a);
}

int main()
{
// Calling functions
function1();
function2();

return 0;
}
Copy code

OUTPUT

The number is 23
The number is 23

UNIT 3
1. Explain the Concept of while loop in C with example.
2. WAP in to print following pattern
ABCDE
ABCD
ABC
AB
A

3. Explain the Concept of Break and Continue Statement.

4. Differtiate While and do while statement with their flow chart.

5.one program given to find error or output.

6. write ternary operator/Conditional operator.

UNIT 4

1. Explain array within structure.


OR
Explain array of structure with the help of suitable program. Describe structure within
structure.

2. Differentiate structure and union.


3. Explain pointer to pointer

OR

Explain double pointer in with example.

4. Explain the Concept of 1 D array and 2 array in C.How to store it in memory.


5. Write a program to pass matrix as an argument to a function and display the matrix in
the function.
6. W A P for array of Pointers.
7. Explain the concept of structure.WAP to create customerdeatails (Customer_ID,
CUST_Name, Purchase_amount) for 5 customers.print the details all of them.
8. Write a program for memory allocation.
9. Short notes on
1) ENUM 2)Command line argument 3)Void Pointer
Command line argument
int main(int argc, char *argv[])
 argc (ARGument Count) is an integer variable that stores the number of command-line
arguments passed by the user including the name of the program. So if we pass a value to a
program, the value of argc would be 2 (one for argument and one for program name)
 The value of argc should be non-negative.
 argv (ARGument Vector) is an array of character pointers listing all the arguments.
 If argc is greater than zero, the array elements from argv[0] to argv[argc-1] will contain
pointers to strings.
 argv[0] is the name of the program , After that till argv[argc-1] every element
is command -line arguments
// C program named mainreturn.c to demonstrate the working
// of command line arguement
#include <stdio.h>

// defining main with arguments


int main(int argc, char* argv[])
{
printf("You have entered %d arguments:\n", argc);

for (int i = 0; i < argc; i++) {


printf("%s\n", argv[i]);
}
return 0;
}
Unit 5

1. Explain the Concept of recursive function with one program.


2. W.A.P. to read data from the keyboard and write into a file then read the same data
from that file.
OR

W.A.P to read and write data from/in file.

3. Write C statement for passing a structure to a function.

How to Pass a structure as an argument to the functions?


When passing structures to or from functions in C, it is important to keep in mind that the entire
structure will be copied. This can be expensive in terms of both time and memory, especially for
large structures. The passing of structure to the function can be done in two ways:

 By passing all the elements to the function individually.


 By passing the entire structure to the function.

By passing the entire structure to the function.

1) Call by Value
 struct car {
 char name[30];
 int price;
 };

 void print_car_info(struct car c)
 {
 printf("Name : %s", c.name);
 printf("\nPrice : %d\n", c.price);
 }

 int main()
 {
 struct car c = { "Tata", 1021 };
 print_car_info(c);
 return 0;
 }
1) Call by References
 struct car {
 char name[30];
 int price;
 };

 void print_car_info(struct car *c)
 {
 printf("Name : %s", c->name);
 printf("\nPrice : %d\n", c->price);
 }

 int main()
 {
 struct car c = { "Tata", 1021 };
 print_car_info(&c);
 return 0;
 }

Passing structure individually elements

struct date{
int day;
int mon;
int yr;
};
main ( ){
struct date d= {02,01,2010}; // struct date d;
display(d.day, d.mon, d.yr);// passing individual mem as argument to
function
getch ( );
}
display(int a, int b, int c){
printf("day = %d
", a);
printf("month = %d
",b);
printf("year = %d
",c);
}

4.Write a program for passing array to function.


#include <stdio.h>
#include <stdlib.h>

void func(int arr[8])


{
printf("Size of arr[] in func(): %d bytes",
sizeof(arr));
}

int main()
{
int arr[8] = { 1, 2, 3, 4, 5, 6, 7, 8 };

printf("Size of arr[] in main(): %dbytes\n",


sizeof(arr));

func(arr);

return 0;
}

void print(int arr[M][N])


{
int i, j;
for (i = 0; i < M; i++)
for (j = 0; j < N; j++)
printf("%d ", arr[i][j]);
}

int main()
{
int arr[][3] = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}};
print(arr);
return 0;
}

5.Explain all storage Classes.

6.write a programe to read character one by one and display it back.

OR

How to enter a string and print it.

#include <stdio.h>

int main()
{
char array[100];
int i,n;

printf(“Enter length of string”);

scanf(“%d”,&n);

printf(“Enter a string character by character “);

for (i=0;i<=n-1;i++)

{
scanf("%c", array[i]);

For(i=0;array[i]!=’\0’;i++)

printf("Your string: %c", array[i]);


}

return 0;
}
7.WAP to copy one string into another string.

8.wtite notes on following

1)fseek()

2)fread()

3)fwite()

4)fputc()

5)fgetc()

You might also like