0% found this document useful (0 votes)
2 views20 pages

Computing Sugg

The document provides a comprehensive overview of computing fundamentals and C programming, covering topics such as computer generations, definitions, memory systems, and programming concepts. It includes detailed explanations of various components, operations, and programming constructs, along with examples and code snippets. Key differences between technologies like CLI vs GUI, routers vs switches, and structures vs unions are also highlighted.

Uploaded by

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

Computing Sugg

The document provides a comprehensive overview of computing fundamentals and C programming, covering topics such as computer generations, definitions, memory systems, and programming concepts. It includes detailed explanations of various components, operations, and programming constructs, along with examples and code snippets. Key differences between technologies like CLI vs GUI, routers vs switches, and structures vs unions are also highlighted.

Uploaded by

byteknightmovies
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Fundamentals of Computing & C Programming

Complete Questions & Answers


1. Computer Generations

Question: Describe the different generations of computers with their characteristics and
history.

Answer:
Computer generations refer to the development of computers based on the major technology
used in each period.

First Generation (1940–1956):

• Used vacuum tubes.


• Very large in size.
• Consumed a lot of electricity.
• Produced much heat.
• Used machine language.
• Examples: ENIAC, UNIVAC-I.

Second Generation (1956–1963):

• Used transistors.
• Smaller, faster and more reliable.
• Consumed less power.
• Assembly and high-level languages were used.
• Example: IBM 1401.

Third Generation (1964–1971):

• Used Integrated Circuits (ICs).


• Smaller and more reliable.
• Operating systems were introduced.
• Example: IBM System/360.

Fourth Generation (1971–Present):

• Used microprocessors.
• Personal computers became popular.
• Smaller, faster and cheaper.
• Examples: Desktop computers and laptops.
Fifth Generation:

• Based on Artificial Intelligence (AI).


• Uses machine learning, parallel processing and natural language processing.
• Example: Modern AI-based computer systems.

2. Definition of Computer
Question: What is a computer? Explain its basic working principle.

Answer:
A computer is an electronic device that accepts data as input, processes it according to
instructions, produces meaningful information as output, and stores the results for future use.

Basic working principle:

Input → Processing → Output → Storage

1. Input: Data and instructions are entered.


2. Processing: CPU processes the data.
3. Output: The processed result is presented.
4. Storage: Data and results are stored for future use.

3. Block Diagram of Computer System


Question: Draw and explain the block diagram of a computer system.

Answer:

+----------------+
| INPUT UNIT |
+--------+-------+
|

+-----------+-----------+
| CPU |
| +------+ +-------+ |
| | ALU | | CU | |
| +------+ +-------+ |
+-----------+-----------+
|
+--------+-------+
| MEMORY UNIT |
+--------+-------+
|

+--------+-------+
| OUTPUT UNIT |
+----------------+
Input Unit: Accepts data and instructions. Examples: keyboard, mouse, scanner.

CPU: The brain of the computer.

• ALU: Performs arithmetic and logical operations.


• CU: Controls and coordinates all activities.

Memory Unit: Stores data, instructions and results.

Output Unit: Displays processed information. Examples: monitor, printer and speaker.

4. CLI vs GUI
Question: Differentiate between CLI and GUI.

Answer:

CLI (Command Line Interface):


An interface where users interact with a computer by typing commands.

GUI (Graphical User Interface):


An interface where users interact through graphical elements such as icons, windows and menus.

CLI GUI

Uses typed commands. Uses graphical elements.

Requires command knowledge. Easy to learn and use.

Mostly keyboard-based. Uses mouse, keyboard, touch, etc.

Uses fewer resources. Generally uses more resources.

Example: Command Prompt Example: Windows Desktop

5. LAN, MAN and WAN


Question: Differentiate between LAN, MAN and WAN.
Answer:

LAN: Local Area Network. It covers a small geographical area such as a room, office, school or
building.

MAN: Metropolitan Area Network. It covers a city or metropolitan area.

WAN: Wide Area Network. It covers a very large geographical area such as countries or
continents.

LAN MAN WAN

Small area City area Very large area

High speed Medium/high speed Generally lower than LAN

Low cost Moderate cost Higher cost

Office/lab network City network Internet

6. Router vs Switch
Question: Explain the differences between a router and a switch.

Answer:

A Router connects different networks and forwards data packets between them.

A Switch connects multiple devices within the same network and forwards data to the
appropriate device.

Router Switch

Connects different networks. Connects devices in the same network.

Uses IP addresses. Uses MAC addresses.

Mainly works at Network Layer. Mainly works at Data Link Layer.

Connects LAN to other networks/Internet. Connects devices within a LAN.


7. Memory System
Question: What is memory? Explain Primary and Secondary Memory.

Answer:
Memory is the part of a computer system used to store data, instructions and results.

Primary Memory

Primary memory is directly accessible by the CPU.

Examples: RAM, ROM and Cache.

• RAM is volatile.
• ROM is non-volatile.

Secondary Memory

Secondary memory provides permanent and large-capacity storage.

Examples: HDD, SSD, Pen Drive, Memory Card and CD/DVD.

Primary Memory Secondary Memory

Directly accessible by CPU Used for permanent storage

Faster Slower

Usually smaller capacity Usually larger capacity

RAM, ROM, Cache HDD, SSD, Pen Drive

8. Memory Hierarchy
Question: What is memory hierarchy? Explain it.

Answer:
Memory hierarchy is the arrangement of different types of memory according to speed, capacity
and cost.
Registers

Cache Memory

Main Memory

Secondary Memory

Tertiary Storage

1. Registers: Fastest memory inside the CPU.


2. Cache: Stores frequently used data and instructions.
3. Main Memory: Stores currently used programs and data.
4. Secondary Memory: Provides permanent storage.
5. Tertiary Storage: Mainly used for backup and archival purposes.

As we move downward, speed decreases, capacity increases and cost per bit decreases.

9. Components of an Email
Question: Describe the different components of an email.

Answer:

1. To: Main recipient's email address.


2. Cc: Sends a copy to additional recipients.
3. Bcc: Sends a hidden copy.
4. Subject: Title of the email.
5. Body: Main message.
6. Attachment: Files attached to the email.
7. Signature: Sender's name and information.

10. Email Operation


Question: Explain the operational process of an email system.

Answer:

The basic email process is:

Compose → Send → Mail Server → Receive → Read


1. Sender composes the email.
2. Recipient's email address is entered.
3. Email is sent to the mail server.
4. SMTP is used for sending/transfer.
5. Recipient's mail server receives and stores the email.
6. Recipient accesses the email using POP3 or IMAP.
7. The email can be replied to, forwarded, deleted or organized.

11. Structure of a C Program


Question: Explain the basic structure of a C program with an example.

Answer:

#include <stdio.h>

int main()
{
int a, b, sum;

printf("Enter two numbers: ");


scanf("%d %d", &a, &b);

sum = a + b;

printf("Sum = %d", sum);

return 0;
}

Main parts:

1. Preprocessor section – #include <stdio.h>


2. main() function
3. Variable declaration
4. Input
5. Processing
6. Output
7. return 0
12. Compiler vs Interpreter
Question: Differentiate between compiler and interpreter.

Compiler Interpreter

Translates the whole program. Translates line by line.

Execution is faster after compilation. Generally slower.

Usually does not produce a separate


Produces object/executable code.
executable.

Errors are generally reported after


Errors are reported line by line.
compilation.

Example: C compiler Example: Python interpreter

13. Algorithm vs Flowchart


Question: Differentiate between algorithm and flowchart.

Answer:

An algorithm is a step-by-step procedure for solving a problem.

A flowchart is a graphical representation of an algorithm using standard symbols and arrows.

Algorithm Flowchart

Written in steps. Represented graphically.

Uses words. Uses symbols and arrows.

Easy to write and modify. Easy to understand visually.

Does not require standard symbols. Uses standard symbols.


14. Pseudocode
Question: What is pseudocode? Explain its uses.

Answer:
Pseudocode is an informal way of writing the steps of a program using simple English-like
statements.

Example:

START
INPUT A, B
SUM = A + B
PRINT SUM
STOP

Uses:

• Helps plan a program.


• Easy to understand.
• Language independent.
• Makes coding easier.

15. Operators and Input-Output


Question: What are operators in C? Explain different types with examples.

Answer:
An operator is a symbol that performs an operation on one or more operands.

Types:

Arithmetic: + - * / %

sum = a + b;

Relational: < > <= >= == !=

Logical: && || !

Assignment: = += -= *= /=

Increment/Decrement: ++ --
Bitwise: & | ^ ~ << >>

Input/Output

printf() is used for output and scanf() is used for input.

int a;

printf("Enter a number: ");


scanf("%d", &a);

printf("Number = %d", a);

16. Data Types


Question: Explain different data types used in C with examples.

Answer:

A data type specifies the type of data that a variable can store.

Data Type Example

int int age = 20;

char char grade = 'A';

float float price = 25.5;

double double x = 25.5678;

Other types include:

• Array
• Pointer
• Structure
• Union
• Enumeration
17. Loops
Question: Explain entry-controlled and exit-controlled loops. Explain for, while and do-
while loops.

Answer:

Entry-Controlled Loop

The condition is checked before executing the loop.

Examples:

• for
• while

for Loop
for(initialization; condition; increment)
{
statement;
}

Example:

for(int i=1; i<=5; i++)


{
printf("%d ", i);
}

while Loop
int i=1;

while(i<=5)
{
printf("%d ", i);
i++;
}

Exit-Controlled Loop

The condition is checked after executing the loop.

do-while Loop
int i=1;

do
{
printf("%d ", i);
i++;
} while(i<=5);

Important: A do-while loop executes at least once.

18. Increment and Decrement Operators


Question: Explain pre/post increment and pre/post decrement operators.

Answer:

Pre-Increment
++a;

First increases the value, then uses it.

Post-Increment
a++;

First uses the value, then increases it.

Pre-Decrement
--a;

First decreases the value, then uses it.

Post-Decrement
a--;

First uses the value, then decreases it.

Example:

int a=5;
int b=++a;

Here:

a = 6, b = 6

int x=5;
int y=x++;

Here:

x = 6, y = 5

19. Function
Question: What is a function? Explain the types of functions in C.

Answer:
A function is a block of code that performs a specific task and can be called whenever required.

Types of Functions

1. Library Functions:
Predefined functions.

Examples:

printf();
scanf();
strlen();
sqrt();

2. User-Defined Functions:
Functions created by the programmer.

void hello()
{
printf("Hello");
}

Based on arguments and return value:

1. No argument, no return value.


2. Argument, no return value.
3. No argument, return value.
4. Argument, return value.
20. Leap Year Program
Question: Write a C program to check whether a year is a leap year or not.

#include <stdio.h>

int main()
{
int year;

scanf("%d", &year);

if(year % 400 == 0 ||
(year % 4 == 0 && year % 100 != 0))
printf("Leap Year");
else
printf("Not a Leap Year");

return 0;
}

21. Prime Number Program


Question: Write a C program to check whether a number is prime or not.

#include <stdio.h>

int main()
{
int n, i, flag = 0;

scanf("%d", &n);

if(n <= 1)
flag = 1;

for(i = 2; i <= n/2; i++)


{
if(n % i == 0)
{
flag = 1;
break;
}
}

if(flag == 0)
printf("Prime Number");
else
printf("Not a Prime Number");
return 0;
}

22. Even and Odd Program


Question: Write a C program to determine whether a number is even or odd.

#include <stdio.h>

int main()
{
int n;

scanf("%d", &n);

if(n % 2 == 0)
printf("Even Number");
else
printf("Odd Number");

return 0;
}

23. Swap Without Third Variable


Question: Write a C program to swap two variables without using a third variable.

#include <stdio.h>

int main()
{
int a, b;

scanf("%d %d", &a, &b);

a = a + b;
b = a - b;
a = a - b;

printf("a = %d\n", a);


printf("b = %d\n", b);

return 0;
}
24. Structure vs Union
Question: Differentiate between Structure and Union in C.

Answer:

A structure groups different data members together, and each member has its own storage. A
union also groups different members, but its members share the same memory area; normally
only one member's value is intended to be used at a time.

Structure Union

Uses struct keyword. Uses union keyword.

Each member gets separate memory. Members share the same memory.

Can store values of all members Normally stores one meaningful member
simultaneously. value at a time.

Size is approximately based on all members Size is based mainly on its largest
plus alignment. member plus alignment.

Changing one member does not normally Writing one member can overwrite the
affect other members. shared storage.

Example
struct Student
{
int id;
float marks;
char grade;
};
union Data
{
int id;
float marks;
char grade;
};

25. Passing Array to a Function


Question: Explain how an array is passed to a function using a pointer.
Answer:
When an array name is passed to a function, it represents the address of its first element.
Therefore, the function can receive it using a pointer parameter.

#include <stdio.h>

void display(int *arr, int n)


{
int i;

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


{
printf("%d ", *(arr+i));
}
}

int main()
{
int arr[] = {10, 20, 30, 40, 50};

display(arr, 5);

return 0;
}

Here, arr is passed to the function and int *arr receives the address of the first element.

26. File Operations


Question: Explain file operations in C with a suitable program.

Answer:
File handling is used to store data permanently in files.

Common File Operations

1. Create
2. Open
3. Read
4. Write
5. Append
6. Close
Common Functions

• fopen() – opens a file


• fclose() – closes a file
• fprintf() – writes formatted data
• fscanf() – reads formatted data
• fgetc() – reads a character
• fputc() – writes a character

File Modes

r = Read
w = Write
a = Append
r+ = Read and Write
w+ = Write and Read
a+ = Append and Read

Example
#include <stdio.h>

int main()
{
FILE *fp;

fp = fopen("[Link]", "w");

fprintf(fp, "Hello World");

fclose(fp);

return 0;
}

27. Variable Swapping


Question: Explain the concept of variable swapping and write different methods.

Answer:
Variable swapping means exchanging the values of two variables.

If:

A = 10 and B = 20
After swapping:

A = 20 and B = 10

Using Third Variable


temp = a;
a = b;
b = temp;

Without Third Variable


a = a + b;
b = a - b;
a = a - b;

Using XOR
a = a ^ b;
b = a ^ b;
a = a ^ b;

28. Call by Value and Call by Reference


Question: What is Call by Value and Call by Reference? Write their differences.

Call by Value

In Call by Value, a copy of the actual argument's value is passed to the function. Therefore,
changes made inside the function do not change the original variable.

Example:

#include <stdio.h>

void change(int x)
{
x = 20;
}

int main()
{
int a = 10;

change(a);

printf("%d", a);

return 0;
}
Output:

10

Call by Reference

In C textbooks, Call by Reference usually means passing the address of a variable using a
pointer so the function can modify the original variable. Strictly speaking, C itself passes the
pointer argument by value.

Example:

#include <stdio.h>

void change(int *x)


{
*x = 20;
}

int main()
{
int a = 10;

change(&a);

printf("%d", a);

return 0;
}

Output:

20

Differences
Call by Value Call by Reference*

A copy of the value is passed. Address/pointer to the original variable is passed.

Original value is not changed. Original value can be changed.

Does not require pointer operators. Uses pointers (* and &) in C.

Safer when original data should not Useful when the function needs to modify original
change. data.

Example: fun(a); Example: fun(&a);

You might also like