Chapter-1
NETWORKING AND TELECOMMUNICATION
A. Short answers questions:
1. What is data communication?
= Data
communication is the exchange of data between devices via some form of
transmission medium.
2. List out the components of data
communication.
= The components
of data communication are as follows:
i) Sender
ii) Receiver
iii) Medium
iv) Protocols
v) Interfaces.
3. What is computer network?
= A computer network is a collection of interconnected devices that can
communicate and share resources.
4. What do you mean by server and
workstation?
= A server is a central computer that provides data or services to other
devices on the network, while a workstation is a personal computer used by an
individual for tasks such as data processing or software development.
5. What do you mean by dedicated server and
non-dedicated server?
= A dedicated server is exclusively allocated to serve the needs of one
user or organization, while a non-dedicated server may serve multiple users or
purposes.
6. What is Network Interface Card? Why does
it require in computer?
= A Network Interface Card (NIC) is a hardware component that enables a
device to connect to a network.
It's required in computers to
facilitate communication over a network.
7. What is transmission media? List its
types.
= Transmission media refers to the physical pathways through which data
travels in a network.
Its types are as follows:
i)
Guided or bounded or wired transmission media
ii)
Unguided or Unbounded or Wireless transmission media
8. What is bandwidth? What is the measuring
unit of bandwidth?
=
Bandwidth is the capacity of a communication channel to transmit data.
Its measuring unit is
typically bits per second (bps) or a multiple thereof, such as Mbps or Gbps.
9. What is guided transmission media? List
any three guided transmission media.
= Guided transmission media are those that use a physical conductor to
transmit data.
Some guided transmission medias are as
follows:
i)
Twisted pair cable
ii) Coaxial
cable,
iii) Fiber
optic cable
iv) Wireless transmission.
10. What
is unguided transmission media? List any three unguided transmission media.
= Unguided transmission media, also known as
wireless media, transmit data through the air without the use of a physical
conductor.
Some unguided transmission
medias are as follows:
i) Radio
waves
ii)
Microwaves
iii) Infrared.
11. What is the role of modem in data
transmission?
= A modem (modulator-demodulator) converts
digital data from a computer into analog signals for transmission over analog
communication lines, and vice versa. It enables communication between digital
devices over analog networks.
12. Different between VTP and STP cable.
= VTP (Twisted Pair) and STP (Shielded Twisted
Pair) cables differ in their shielding capabilities, with STP offering better
protection against electromagnetic interference.
13. Difference between Hub and Switch.
= A hub operates at the physical layer of the
OSI model and simply forwards data to all connected devices, while a switch
operates at the data link layer and intelligently routes data only to the
intended recipient, improving network efficiency.
14. Difference between Server and
Workstation.
= A server is a central computer that provides
data or services to other devices on the network, while a workstation is a
personal computer used by an individual for tasks such as data processing or
software development.
15. What is network topology? List the three
basis topologies.
= Network topology refers to the physical or
logical layout of devices on a network. Basic topologies include bus, star, and
ring.
16. What is communication protocol? List any
four network protocols.
= A
communication protocol is a set of rules and conventions that govern how data
is transmitted and received between devices in a network. Examples include
TCP/IP, HTTP, FTP, and SMTP.
B. Long answer questions.
1. What are the different data transmission
modes? Explain about them.
= The different data transmission modes are
as follows:
i. Simplex Mode:
In
simplex mode, data is transmitted in only one direction. One device is the
sender, and the other device is the receiver. The receiver can only receive
data and cannot send any back. Examples of simplex mode include television and
radio broadcasting.
b. Half-Duplex Mode:
In
half-duplex mode, data can be transmitted in both directions, but not
simultaneously. Devices can both send and receive data, but not at the same
time. Instead, they take turns transmitting and receiving. Walkie-talkies are
an example of half-duplex mode.
c. Full-Duplex Mode:
In
full-duplex mode, data can be transmitted simultaneously in both directions.
This means that devices can send and receive data at the same time without
having to take turns. Ethernet connections and telephone networks using
separate lines for sending and receiving data are examples of full-duplex mode.
2. Write any four advantages and disadvantages
of computer network.
= Four advantages of computer network are as follows:
i) Communication: Enables seamless communication
and collaboration among users.
ii) Resource Sharing: Facilitates sharing of hardware, software, and data resources.
iii) Cost Efficiency: Reduces costs associated with hardware and software duplication.
iv) Accessibility: Allows remote access to resources, enhancing flexibility and productivity.
Four disadvantages of
computer network are as follows:
i) Security
Risks: Vulnerable to cyber threats like hacking, malware, and data breaches.
ii) Dependency: Network failures can disrupt operations and cause downtime.
iii) Complexity: Maintenance and management of network infrastructure require expertise.
iv) Privacy Concerns: Raises issues of privacy infringement and unauthorized access to sensitive information.
3. Computer Network Reduces Expenses of an
Office justify this statement with examples.
= Computer networks can indeed reduce expenses for an office in several
ways:
a. Resource Sharing:
By
connecting multiple computers and devices to a network, resources such as
printers, scanners, and storage devices can be shared among users. This reduces
the need for each individual user to have their own dedicated resources,
leading to cost savings on hardware and maintenance.
b. Centralized Services:
Networks
allow for the centralization of services such as file storage, email, and
internet access. Instead of each user having their own email server or internet
connection, these services can be provided centrally, reducing costs associated
with purchasing and maintaining multiple servers or connections.
c. Remote Access:
With a
network in place, employees can access files, applications, and resources from
remote locations, reducing the need for expensive business travel and
facilitating remote work arrangements. This can lead to savings on travel
expenses and office space.
d. Efficiency:
Computer
networks enable streamlined communication and collaboration among employees,
leading to increased productivity and efficiency. Tasks such as document
sharing, project management, and scheduling can be handled more efficiently
through networked systems, reducing operational costs.
4. What is local area network? Why are
computers kept on the LAN?
= A Local Area Network (LAN) is a network
that connects computers and devices within a limited geographical area, such as
a home, office, or school. Computers are kept on LANs for easier sharing of
resources like files, printers, and internet connections, as well as for
communication between devices.
5. What is metropolitan area network? Why is it called
composed of LANS
= A
Metropolitan Area Network (MAN) is a network that covers a larger geographical
area than a LAN but is still confined to a city or metropolitan area. It's
composed of LANs because it connects multiple LANs within a city.
6. What is wide area network? Why is it called composed of
LANs and MANS?
= A Wide
Area Network (WAN) is a network that spans a large geographical area, such as
multiple cities or countries. It's called composed of LANs and MANs because it
connects LANs within different locations, often across long distances.
7. Write the differences between client-server network and
peer-to-pee network model.
= In a
client-server network model, clients request services or resources from
servers. Servers are dedicated computers that provide services like file
storage, email, or website hosting. In a peer-to-peer network model, all
computers are considered equal and can act as both clients and servers, sharing
resources directly without a dedicated server.
8. What is bus topology? List its advantages and
disadvantages.
= In this topology,
all devices are connected to a single cable called a bus. Advantages include
simplicity of design and low cost, while disadvantages include the potential
for network congestion and failure if the main cable fails.
9. What
is ring topology? List its advantages and disadvantages.
= In this
topology, devices are connected in a circular manner, where each device is
connected to two other devices forming a ring. Advantages include simplicity
and equal access to the network, while disadvantages include the entire network
being affected if one device fails and potential for network congestion.
10. What is star topology? List its advantages and
disadvantages.
= In this topology,
all devices are connected to a central hub or switch. Advantages include easy
troubleshooting and scalability, while disadvantages include dependency on the
central hub and potential for network congestion.
11. Define TCP/IP, HTTP, FTP, SMTP and POP protocols
= TCP/IP (Transmission
Control Protocol/Internet Protocol) is the set of protocols used for internet
communication.
HTTP (Hypertext Transfer
Protocol) is used for transmitting web pages over the internet.
FTP (File Transfer
Protocol) is used for transferring files between computers on a network.
SMTP (Simple Mail
Transfer Protocol) is used for sending email, and
POP (Post
Office Protocol) is used for retrieving email from a mail server.
C. Full form:-
1. STP - Shielded Twisted Pair
2. UTP - Unshielded Twisted Pair
3. NIC - Network Interface Card
4. LAN - Local Area Network
5. MODEM - Modulator-Demodulator
6. MAN - Metropolitan Area Network
7. WAN - Wide Area Network
8. WLAN - Wireless Local Area Network
9. TCP/IP - Transmission Control
Protocol/Internet Protocol
10. SMTP - Simple Mail Transfer Protocol
11. POP - Post Office Protocol
12. FTP - File Transfer Protocol
13. MAC - Media Access Control
14. ISP - Internet Service Provider
D. Technical Term:-
1. The transmission of data or information
between computers:
=Data Communication
2. Transferring of data and information over
significant distances:
=Wide Area Network (WAN)
3. Mode of transmission that transmits data
in only one direction:
=Simplex
4. Mode of transmission that can alternately
send and receive data:
=Half-duplex
5. Mode of transmission that can send and
receive data simultaneously:
= Full-duplex
6. The data handling capacity of a
communication system:
=Bandwidth
7. The amount of data transmitted per second
through the communication channel:
= Data Rate
8. A group of interconnected computers:
= Network
9. A computer on a network:
=Node
10. A computer on the network that controls
and provides resources:
= Server
11. A computer on the network that uses the
resources of the network:
= Client
12. The computer that works stationontrol
authority and regulates communication to other stations:
= Network Controller
13. A server computer that does not allow a
user to perform application tasks on
it:
= Dedicated Server
14. A server computer that allows a user to
perform application tasks on it:
= Application
Server
15. A server computer that provides files
related services:
= File
Server
16. A server that provides database services:
= Database
Server
17. A server that provides internet services:
= Web
Server
18. A card through which a computer is
connected on the network: Network
= Interface
Card (NIC)
19. A device that works like a physical
interface between cabling and network
nodes:
= Hub
20. A path through which data is transmitted
from one computer to another:
= Data
Transmission Path
21. The amount of data transmitted per second
through a communication channel:
= Data
Transfer Rate
22. The data handling capacity of a
communication channel:
= Channel
Capacity
23. A transmission media that uses network
cables:
= Wired
Media
24. A transmission medium that guides data
along a specified path:
= Guided
Media
25. The computer network which uses bounded
media:
= Wired
Network
26. A network of computers formed by using
unguided media:
= Wireless
Network
27. A transmission medium through which data
are transmitted in the form of light:
= Optical
Fiber
28. An operating system used in a server
computer:
= Server
Operating System
29. A network device that retransmits signals
to all nodes on the network:
= Hub
30. A multiport repeater:
= Switch
31. A network device that retransmits signals
to a destination node on the network:
= Switch
32. A network device that connects segments
of the same or different networks having
the same protocol:
= Router
33. A network device that can determine the
best path for forwarding data packets:
= Router
34. A network device that joins networks
having different protocols:
= Gateway
35. A device that converts digital signals
into analog signals and vice versa:
= Modem
36. The conversion of digital signals into
analog signals:
= Modulation
37. The conversion of analog signals into
digital signals:
= Demodulation
38. A network of computers in a room,
building, or campus:
= Local
Area Network (LAN)
39. A computer network that is spread within
a city or neighboring cities:
= Metropolitan
Area Network (MAN)
40. A network of computers that covers the
whole world:
= Wide
Area Network (WAN)
41. The network model where there is at least
one server:
= Client-Server
Model
42. The network model where each node has an
equal right:
= Peer-to-Peer
Model
43. The cabling pattern of interconnected
nodes.
= Mesh Topology
44. The
cabling pattern of computers where each computer is connected to a common cable in
the linear format.
= Bus Topology
45. The cabling pattern of computers where all
the nodes are connected in
a closed loop.
= Ring Topology
46. The cabling pattern of computers where
each node is individually connected to
a centrally located device.
= Star Topology
47. A set of rules by which computers on the
network communicate with each other.
= Protocol
48. A
native protocol of the Internet.
= TCP/IP (Transmission
Control Protocol/Internet Protocol)
49. A protocol that allows a user on one host
to access and transfer files to another
network.
= FTP (File Transfer Protocol)
50. A
network protocol that transmits electronic mail from one server to another server.
= SMTP (Simple Mail
Transfer Protocol)
51. A network protocol that receives e-mail
from an email server.
= POP3 (Post Office Protocol version 3)
52.
Software that is used for surfing information through the internet.
= Web Browser
D. True or False:
1. In a communication system a sender
generates or creates messages to be transferred.
True
2. In the simplex, the transmission of data
can take place in both directions. False
3. A full duplex device can send and receive
data simultaneously at a time. True
4. A computer on the network can share hardware
only.
False
5. A server acts as the controller, storehouse
and distributor of data, information and programs.
True
6. A non-dedicated server does not allow a user
to perform application tasks on it.
True
7. A dedicated server allows a user to
perform application tasks on it.
False
8. Windows NT Server, Novell Netware Server and
Windows XP are network operating systems.
True
9. The network can have only one workstation.
False
10 A workstation is the computer that uses the
services of the network.
True
11. A node address of a NIC helps us to identify
a computer on the network.
True
12. The high bandwidth channel is known as
broadband channel.
True
13. A coaxial cable is used in Star topology.
False
14 Data are transmitted in the form of light in
the fiber optic cable.
True
15. In the wired network, computers are
connected with each other through wires.
True
16. Microwave signals travel in straight line
and cannot pass through obstacles like buildings, hills, etc.
False
17. A hub is also called multiport repeater.
True
18. A switch reduces the network traffic and
improves the network performance.
True
19. Multiple bridges can be used to form a large
network by connecting several small networks.
True
20. A repeater is a network device that regenerates
electric signals.
True
21. A NIC converts digital signals into analog
signals and vice versa.
False
22. In the star topology computers must be
arranged in the form of star.
False
23. A computer network that covers small local
area is MAN.
False
24. Internet is an example of WAN.
True
25. You can send messages from one computer to
another computer on the network.
True
F. Choose the correct
answer:
1. Which of the device is simplex?
a) Television
b) Telephone
c) Computer
d) None of the above
2. Walkie-Talkie is the example of.....
a) Simplex
b) Half Duplex
c) Full Duplex
d) None of the above
3. The term network basically refers to
a) Communication
b) Interconnection
c) Sharing
d) All of the above
4. The bandwidth of digital signal is
measured in
a) Hertz
b) Cycle per second
c) Bits per second
d) None of the above.
5. The computer network enables us to
share..........
a) Hardware
b) Data
c) Software
d) All of the above
6. Which is not network operating system?
a) Windows NT Server
b) Windows 98
c) Windows Server 2003
d) None of them
7. A workstation computer can
have.......operating system.
a) Windows 98
b) Window NT Workstation
c) Windows XP
d) All of them
8. Which is not the guided medium?
a) UTP
b) STP
c) Microwave
d) Fiber optic cable
9. Which is the connector of UTP cable?
a) BNC
b) T-Connector
c) ST connector
d) RJ-45 connector
10. Which the network operating system used
in a server computer?
a) Novell Netware Server
b) Windows Vista
c) Windows NT server.
d) All of them.
11. A dedicated server that manages printers
and printing jobs is......
a) Network Server
b) Printer Server
c) Modem Server
d) File Server.
12. A networking device that joins multiple
networks having different protocols is ....
a) Switch
b) Router
c) Gateway
d) Bridge
13. Which of the following is transmission
medium?
a) FTP
b) UTP
c) SMTP
d) All of them
14. Which is not the network protocol?
a) TCP/IP
b) STP
c) FTP
d) SMTP
C language Programming
A. Answer the following questions:
1. What is C language?
- C
Language is a high-level,
general-purpose programming language developed in the early 1970s by Dennis
Ritchie at Bell Labs. It is widely used for system and application software,
embedded systems, and for teaching computer programming.
2. Why is C language called a structured
programming language?
- C language is called a structured
programming language because it allows the use of functions, loops,
conditionals, and blocks of code that can be nested and organized to create
clear, efficient, and understandable programs.
3. Why is C language called a middle-level
language?
- C language is called a middle-level
language because it combines elements of both high-level languages (which are
easier for humans to read and write) and low-level languages (which are closer
to machine code and offer fine control over hardware).
4. Why is C language more popular than
QBASIC?
- C language is more popular than QBASIC because
it offers greater flexibility, efficiency, and performance. It is also more
versatile, being used for a wide range of applications, from operating systems
and compilers to games and business applications, whereas QBASIC is limited
mainly to educational purposes and simple scripting.
5. List any two features of C language.
- 1) Portability: C programs can run on
different machines with little or no modification.
2) Rich
Library: C has a rich set of built-in functions and operators.
6. Define Source code and Object code.
- Source code: The original code written by the programmer in a
high-level programming language.
- Object code: The machine code or intermediate code generated after
the source code is compiled by a compiler.
7. List two similarities of QBASIC and C
language.
- 1) Both are procedural programming languages.
2) Both
can be used to write structured programs using loops, conditionals, and
functions/subroutines.
8. List any two differences between QBASIC
and C language.
- 1) C language has a more complex syntax
and more powerful features compared to the simpler syntax and limited features
of QBASIC.
2) C language supports low-level memory
manipulation and pointer arithmetic, whereas QBASIC does not.
9. What is an identifier in C language? List
the rules for naming the identifiers.
- An identifier in C language is a name used
to identify variables, functions, arrays, etc.
Rules
for naming identifiers include:
- Must begin with a letter (uppercase or
lowercase) or an underscore (_).
- Can contain letters, digits (0-9), and
underscores.
- Case-sensitive (e.g., `Var` and `var` are
different identifiers).
- Cannot be a reserved keyword (e.g., `int`,
`return`).
10. List the basic data types of C language.
The basic data types in C language are:
- `int` (integer)
- `float` (floating-point number)
- `double` (double-precision floating-point
number)
- `char` (character)
11. What is a data type modifier? List them.
- A data type modifier alters the properties
of the basic data types, such as their size or range. Common data type
modifiers in C include:
- `short`
- `long`
- `signed`
- `unsigned`
12. What is an operator in C language? List
any four operators used in C language.
- An operator in C language is a symbol that
tells the compiler to perform specific mathematical or logical manipulations.
Four operators used in C include:
- `+` (Addition)
- `-` (Subtraction)
- `*` (Multiplication)
- `/` (Division)
13. What is a unary operator in C language?
- A unary operator is an operator that operates
on a single operand. Examples include the increment operator (`++`), the
decrement operator (`--`), the unary plus (`+`), and the unary minus (`-`).
14. What is a logical operator? List its
operators.
- Logical operators are used to perform
logical operations, typically used in conditional statements. The logical
operators in C are:
- `&&` (Logical AND)
- `||` (Logical OR)
- `!` (Logical NOT)
15. What is an assignment operator? List its
operators.
- An assignment operator is used to assign a
value to a variable. The basic assignment operator is `=`, but there are also
compound assignment operators which combine arithmetic operations with
assignment. The assignment operators in C include:
- `=` (Assignment)
- `+=` (Add and assign)
- `-=` (Subtract and assign)
- `*=` (Multiply and assign)
- `/=` (Divide and assign)
- `%=` (Modulus and assign)
16. What is a header file? List any two
header files.
- A header file in C contains declarations
of functions and macros to be shared between several source files. Examples
include:
- `stdio.h` (Standard Input Output header)
- `stdlib.h` (Standard Library header)
17. Write the uses of `printf()` and
`scanf()` function.
- `printf()`: Used to output (print)
formatted text to the standard output (usually the screen).
- `scanf()`: Used to read formatted input
from the standard input (usually the keyboard).
18. What is escape character in C-language?
- An escape character is a backslash (`\`)
followed by a character that has a special meaning. It allows you to include
special characters in strings, such as newline (`\n`), tab (`\t`), backslash
(`\\`), and double quote (`\"`).
B. Write a program in C
language to add 15 and 27.
#include <stdio.h>
int main()
{
int num1 = 15;
int num2 = 27;
int sum = num1 + num2;
printf("The sum of %d and %d is %d\n",
num1, num2, sum);
return 0;
}
C. Program to Add Any
Two Numbers Supplied by a User
#include <stdio.h>
int main()
{
int num1, num2, sum;
printf("Enter first number: ");
scanf("%d", &num1);
printf("Enter second number: ");
scanf("%d", &num2);
sum = num1 + num2;
printf("The sum of %d and %d is %d\n",
num1, num2, sum);
return 0;
}
D. Program to Display Area
of a Rectangle
#include <stdio.h>
int main()
{
float length, width, area;
printf("Enter length of the rectangle:
");
scanf("%f", &length);
printf("Enter width of the rectangle:
");
scanf("%f", &width);
area = length * width;
printf("The area of the rectangle is
%.2f\n", area);
return 0;
}
E. Program to
Display Perimeter of a Rectangle
#include <stdio.h>
int main()
{
float length, width, perimeter;
printf("Enter length of the rectangle:
");
scanf("%f", &length);
printf("Enter width of the rectangle:
");
scanf("%f", &width);
perimeter = 2 * (length + width);
printf("The perimeter of the rectangle is
%.2f\n", perimeter);
return 0;
}
F. Program to
Display Area of Four Walls of a Room
#include
<stdio.h>
int main()
{
float length, width, height, area;
printf("Enter length of the room: ");
scanf("%f", &length);
printf("Enter width of the room: ");
scanf("%f", &width);
printf("Enter height of the room: ");
scanf("%f", &height);
area = 2 * height * (length + width);
printf("The area of the four walls of the
room is %.2f\n", area);
return 0;
}
G. Program to
Display Circumference of a Circle
#include
<stdio.h>
#define PI 3.14159
int main()
{
float radius, circumference;
printf("Enter radius of the circle:
");
scanf("%f", &radius);
circumference = 2 * PI * radius;
printf("The circumference of the circle is
%.2f\n", circumference);
return 0;
}
H. Program to Display
Volume of a Cylinder
#include
<stdio.h>
#define PI 3.14159
int main()
{
float radius, height, volume;
printf("Enter radius of the cylinder:
");
scanf("%f", &radius);
printf("Enter height of the cylinder:
");
scanf("%f", &height);
volume = PI * radius * radius * height;
printf("The volume of the cylinder is
%.2f\n", volume);
return 0;
}
I. Program to Calculate and
Display Profit or Loss
#include <stdio.h>
int main()
{
float costPrice, sellingPrice, profitOrLoss;
printf("Enter cost price: ");
scanf("%f", &costPrice);
printf("Enter selling price: ");
scanf("%f", &sellingPrice);
profitOrLoss = sellingPrice - costPrice;
if (profitOrLoss > 0) {
printf("Profit: %.2f\n",
profitOrLoss);
} else if (profitOrLoss < 0) {
printf("Loss: %.2f\n", -profitOrLoss);
} else {
printf("No profit, no loss.\n");
}
return 0;
}
J. Program to Display
Whether a Number is Positive, Negative or Zero
#include
<stdio.h>
int main() {
int num;
printf("Enter a number: ");
scanf("%d", &num);
if (num > 0) {
printf("The number is positive.\n");
} else if (num < 0) {
printf("The number is negative.\n");
} else {
printf("The number is zero.\n");
}
return 0;
}
K. Program to
Display the Greater Number Among Any Three Numbers Supplied by the User
#include
<stdio.h>
int main()
{
int num1, num2, num3;
printf("Enter three numbers: ");
scanf("%d %d %d", &num1,
&num2, &num3);
if (num1 >= num2 && num1 >= num3)
{
printf("The greatest number is %d\n",
num1);
} else if (num2 >= num1 && num2 >=
num3) {
printf("The greatest number is %d\n",
num2);
} else {
printf("The greatest number is %d\n",
num3);
}
return 0;
}
L. Program to
Display the Smaller Number Among Any Three Numbers Supplied by the User
#include <stdio.h>
int main()
{
int num1, num2, num3;
printf("Enter three numbers: ");
scanf("%d %d %d", &num1,
&num2, &num3);
if (num1 <= num2 && num1 <= num3)
{
printf("The smallest number is %d\n",
num1);
} else if (num2 <= num1 && num2 <=
num3) {
printf("The smallest number is %d\n",
num2);
} else {
printf("The smallest number is %d\n",
num3);
}
return 0;
}
M. Program to Display the
Middle Number Among Any Three Numbers Supplied by the User
#include <stdio.h>
int main() {
int num1, num2, num3;
printf("Enter three numbers: ");
scanf("%d %d %d", &num1,
&num2, &num3);
if ((num1 >= num2 && num1 <= num3)
|| (num1 <= num2 && num1 >= num3)) {
printf("The middle number is %d\n",
num1);
} else if ((num2 >= num1 && num2
<= num3) || (num2 <= num1 && num2 >= num3)) {
printf("The middle number is %d\n",
num2);
} else {
printf("The middle number is %d\n",
num3);
}
return 0;
}
N. Write the program using
C language to generate the following numeric seriese:
1.
Series: 1, 2, 3, 4, 5, ..., up to 20 terms
#include <stdio.h>
int main()
{
for (int i = 1; i <= 20; i++) {
printf("%d ", i);
}
printf("\n");
return 0;
}
2. Series: 100, 90, 80, 70, ………..,10
#include <stdio.h>
int main()
{
for (int i = 100; i >= 10; i -= 10) {
printf("%d ", i);
}
printf("\n");
return 0;
}
3.
Series: 2, 4, 6, 8, ..., up to 15 terms
#include <stdio.h>
int main() {
for (int i = 1; i <= 15; i++) {
printf("%d ", 2 * i);
}
printf("\n");
return 0;
}
4.
Series: 2, 4, 6, 8, ………..22
#include <stdio.h>
int main() {
int series[] = {2, 4, 6, 8, 22};
int length = sizeof(series) / sizeof(series[0]);
for (int i = 0; i < length; i++) {
printf("%d ", series[i]);
}
printf("\n");
return 0;
}
5.
Series: 23, 21, 19,………… 5
#include <stdio.h>
int main() {
int series[] = {23, 21, 19, 5};
int length = sizeof(series) / sizeof(series[0]);
for (int i = 0; i < length; i++) {
printf("%d ", series[i]);
}
printf("\n");
return 0;
}
6.
Series: 2, 2, 4, 6, 10, ..., up to 12 terms
#include <stdio.h>
int main() {
int a = 2, b = 2;
printf("%d %d ", a, b);
for (int i = 3; i <= 12; i++) {
int next = a + b;
printf("%d ", next);
a = b;
b = next;
}
printf("\n");
return 0;
}
7.
Series: 2, 3, 5, 8, 13, ..., up to 12 terms
#include <stdio.h>
int main() {
int a = 2, b = 3;
printf("%d %d ", a, b);
for (int i = 3; i <= 12; i++) {
int next = a + b;
printf("%d ", next);
a = b;
b = next;
}
printf("\n");
return 0;
}
8.
Series: 2, 3, 5, 8, 12, ..., up to 12 terms
#include <stdio.h>
int main() {
int a = 2, b = 3;
printf("%d %d ", a, b);
for (int i = 3; i <= 12; i++) {
int next = a + b + 1;
printf("%d ", next);
a = b;
b = next;
}
printf("\n");
return 0;
}
O. WAP in C language to display
'computer' Ten Times
#include <stdio.h>
int main() {
for (int i = 0; i < 10; i++) {
printf("computer\n");
}
return 0;
}
P. WAP in C language to display Sum of First 10
Counting Numbers
#include <stdio.h>
int main() {
int sum = 0;
for (int i = 1; i <= 10; i++) {
sum += i;
}
printf("The sum of the first 10 counting
numbers is %d\n", sum);
return 0;
}
Q. WAP in C language to display Sum of Any Ten
Numbers Input by a User
#include <stdio.h>
int main() {
int numbers[10], sum = 0;
printf("Enter 10 numbers:\n");
for (int i = 0; i < 10; i++) {
scanf("%d", &numbers[i]);
sum += numbers[i];
}
printf("The sum of the entered numbers is
%d\n", sum);
return 0;
}
R. WAP in C language to display Sum of Odd
Numbers from 3 to 21
#include <stdio.h>
int main() {
int sum = 0;
for (int i = 3; i <= 21; i += 2) {
sum += i;
}
printf("The sum of odd numbers from 3 to 21
is %d\n", sum);
return 0;
}
S. WAP in C language to to
Count and Display Total Number of Factors of a Number
#include <stdio.h>
int main() {
int num, count = 0;
printf("Enter a number: ");
scanf("%d", &num);
for (int i = 1; i <= num; i++) {
if (num % i == 0) {
count++;
}
}
printf("The total number of factors of %d
is %d\n", num, count);
return 0;
}
T. WAP in C language to display Factors of a
Number
#include <stdio.h>
int main() {
int num;
printf("Enter a number: ");
scanf("%d", &num);
printf("The factors of %d are: ",
num);
for (int i = 1; i <= num; i++) {
if (num % i == 0) {
printf("%d ", i);
}
}
printf("\n");
return 0;
}
U. WAP in C language to
Check and Display Whether a Number is Prime or Composite
#include
<stdio.h>
int main() {
int num, i, isPrime = 1;
printf("Enter a number: ");
scanf("%d", &num);
if (num <= 1) {
isPrime = 0;
} else {
for (i = 2; i <= num / 2; i++) {
if (num % i == 0) {
isPrime = 0;
break;
}
}
}
if (isPrime) {
printf("%d is a prime number.\n",
num);
} else {
printf("%d is a composite number.\n",
num);
}
return 0;
}
V. WAP in C language to display Sum of Digits
of a Number
#include
<stdio.h>
int main() {
int num, sum = 0, digit;
printf("Enter a number: ");
scanf("%d", &num);
while (num > 0) {
digit = num % 10;
sum += digit;
num /= 10;
}
printf("The sum of the digits is
%d\n", sum);
return 0;
}
W. WAP in C language to display Reverse of a
Number
#include
<stdio.h>
int main() {
int num, reverse = 0, digit;
printf("Enter a number: ");
scanf("%d", &num);
while (num > 0) {
digit = num % 10;
reverse = reverse * 10 + digit;
num /= 10;
}
printf("The reverse of the number is
%d\n", reverse);
return 0;
}