0% found this document useful (0 votes)
73 views93 pages

MS WORD Project

Download as pdf or txt
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 93

MS WORD

Microsoft word is a word processing application that is part


of the Microsoft Office Suite. Microsoft Office Suite is a set
of powerful applications that are designed to provide a rich
set of tools for almost every conceivable business task for a
small (and large) business or organization. Microsoft Office
Suite has been designed so that the interface across all the
applications is consistent. Obviously, this helps users to move
from application to application to carry out their various
business tasks.

Steps to open MS-WORD:


i. Open your Computer.
ii. Click on windows tab and search for MS-Word.
Alternatively,
i. Press Windows + R.
ii. After run command appears, type win-word.
iii. Your Blank page will be opened.

Rajendra Pradsad Joshi Sec: O1 1


Rajendra Pradsad Joshi Sec: O1 2
Program 1: Congratulation card to a
friend

CONGRATULATIONS
Dear Ram,

Congratulations on your outstanding achievement! Becoming the top scorer in


the board exams is no small feat, and your hard work and dedication have
truly paid off.

May this success be the stepping stone to a bright future filled with even
greater accomplishments. Keep shining, keep striving, and keep making us
proud!

Rajendra Pradsad Joshi Sec: O1 2


Rajendra Pradsad Joshi Sec: O1 3
Rajendra Prasad Joshi

Experience

2015–2019
IT Engineer• Senior Developer • Esewa

2019–2020
IT Engineer• HOD • Daraz

Mid-Baneshwor 2020–2023

Kathmandu,4460 It Engineer• Senior Engineer • Meta

0 I have had worked on plenty of tech giants as a


software engineer as you can already see on the
9867354321 above column.

Education
education@rolex
.com.np Stepping Stone English School, Dhangadhi,
Kailali
I have scored 3.55 as grade point average on the
recent SEE
examination conducted by NEB.

Communication
mrx.com.np
• Excellent written and verbal communication
skills
• Confident, articulate, and professional
speaking abilities (and experience).

Rajendra Pradsad Joshi Sec: O1 4


Leadership

• Able to lead others in high-demand


situations
• Coaching, guiding, or tacking
• Delegating tasks or responsibilities
• Demonstrated leadership.

Rajendra Pradsad Joshi Sec: O1 5


Program 3: Birthday Card using different shapes

HAPPY
BIRTHD
MONDAY, 1 APRIL

AY
7`O CLOCK IN THE
BASUKI
EVENING MARG,
BANESHWOR

6
7
Program 4: Report card of student’s result

STUDENT REPORT CARD


Name: Rajendra Prasad Joshi Grade: 11

Section: O1

Date: 05/04/2024

Subject P.M. F.M. Obtained


Math 40 100 92
Computer 40 100 96
Chemistry 40 100 86
Physics 40 100 93
English 40 100 84
Teacher’s Feedback:
Nepali 40 100 82
_______________________________________________________________________________
_______________________________________________________________________________

Class Teacher Signature Principal Signature


Parent’s Signature

_____________________ _________________
8
________________
9
MS EXCEL
Excel is a commercial spreadsheet application produced and
distributed by Microsoft for Microsoft Windows and Mac OS.
It features the ability to perform basic calculations, use
graphing tools,
create pivot tables and create macros. Excel has the same
basic features as all spreadsheet applications, which use a
collection of cells arranged into rows and columns to organize
and manipulate data. They can also display data as charts,
histograms and line graphs.

Features of MS-Excel:
1) MS-Excel allows us to sort data either in ascending or
descending order.
2) MS-Excel allows us to create different charts such as bar
graph, pie-
charts, line graphs, etc.
3) MS-Excel automatically edits the result if any changes are
made in any of the cells.

Steps to open MS-Excel:

i. Open your Computer.

Rajendra Prasad Joshi Sec : O1 10


ii. Click on windows tab and search for MS-Excel.

Alternatively,

i. Press Windows + R.

ii. After run command appears, type excel.

iii. Your Blank page will be opened.

Program 1: Calculate result of students

Formula:

Total: =SUM (B2:G2)

Rajendra Prasad Joshi Sec : O1 11


Percentage: =H2/600*100

Remark: =IF(AND(B2>=40, C2>=40, D2>=40,


E2>=40),"Pass”, “Fail")

Rajendra Prasad Joshi Sec : O1 12


Program 2: Calculate the total amount

ABOVE USED FORMULA


Total : =PRODUCT (C2 : D2)

TOTAL AMOUNT : =SUM (E2 : E6)

13% VAT : =PRODUCT (0.13, E7)

GRAND TOTAL : =SUM (E7 : E8)

3. CALCULATE BILL AMOUNT

FORMULA USED:

CONSUMED = C2 - D2

Rajendra Pradsad Joshi Sec: O1 8


BILL AMOUNT = =IF(E2<=20, E2*8, IF(AND(E2>20, E2<=250), 20*8+(E2-20)*7.3, 20*8+230*7.3+(E2-
250)*11.5)

Rajendra Pradsad Joshi Sec: O1 9


Program 4: Salary Sheet

FORMULA USED

GROSS SALARY : =PRODUCT ( 0.13, B2)

DEDUCTION : = PRODUCT ( 0.4, C2)

NET SALARY : = C2 - D2

Rajendra Prasad Joshi Sec : O1 10


POWER POINT

PowerPoint (PPT) is a powerful, easy-to-use presentation


graphics software program which allows you to create
professional-looking electronic slide shows. PPT is used to
present information in an organized manner to an individual
or group. Using clip art, sound clips, movie clips, graphs,
organization charts, imported Web screens, and many other
features, you can easily create a presentation that will
impress your audience and convey your message clearly and
professionally.

Features of MS-PowerPoint:
1. MS-PowerPoint allows us to create presentations
using different designing
tools like word art, font designs etc.
2. MS-PowerPoint allows you to add photos
and videos.
3. MS-PowerPoint allows you to apply animations in the
slides.
4. MS-PowerPoint allows you to apply transitional effect
in the texts.

Rajendra Prasad Joshi Sec : O1 11


5. MS-PowerPoint allows you to add clip arts, pie
charts etc.

Steps to open MS-PowerPoint:


i. Open your Computer.
ii. Click on windows tab and search for MS- PowerPoint.

Alternatively,
i. Press Windows + R
ii. After run command appears, type PowerPoint.
iii. Your Blank page will be opened.

Program 1: Presentation on
mathematics

Rajendra Prasad Joshi Sec : O1 12


Rajendra Prasad Joshi Sec : O1 13
Rajendra Prasad Joshi Sec : O1 14
Rajendra Prasad Joshi Sec : O1 15
Rajendra Prasad Joshi Sec : O1 16
Rajendra Prasad Joshi Sec : O1 17
Rajendra Prasad Joshi Sec : O1 18
Rajendra Prasad Joshi Sec : O1 19
Rajendra Prasad Joshi Sec : O1 20
Rajendra Prasad Joshi Sec : O1 21
Rajendra Prasad Joshi Sec : O1 22
Rajendra Prasad Joshi Sec : O1 23
Rajendra Prasad Joshi Sec : O1 24
HTML

HTML, which stands for Hyper Text Markup


Language, is the standard markup language used to
create web pages. It provides a structured way to
organize and format content on the World Wide Web
(WWW). Here's a brief introduction to HTML's
background and characteristics:

HTML was first developed by Tim Berners-Lee in


1990 while working at CERN (European Organization
for Nuclear Research) in Switzerland. It was initially
created as a simple markup language to facilitate
the sharing and exchange of scientific documents
among researchers. Over time, HTML evolved into a
widely adopted standard for creating web pages,
playing a crucial role in the growth and development
of the World Wide Web.

Characteristics:

1. Markup language
2. Platform-Independent
3. Text-Based-Format
4. Semantics
5. Extensible
6. Integration with other technologies

18
Rajendra Prasad Joshi Sec : O1

1. Heading tag

In HTML, the <h1> to <h6> tags are used to define


headings of different levels, ranging from the most
important <h1> to the least important <h6>. These
tags are part of the semantic markup in HTML and
are used to structure and organize content on a web
page.

<!DOCTYPE html>
<html>
<body>

<h1>Heading 1</h1>
<h2>Heading 2</h2>
<h3>Heading 3</h3>
<h4>Heading 4</h4>
<h5>Heading 5</h5>
<h6>Heading 6</h6>

19
Rajendra Prasad Joshi Sec : O1

</body>
</html>

Text Formatting/ Character Formatting

In HTML, you can apply text formatting and


character formatting using various elements and
attributes to style and enhance the appearance of
text on a web page.

<!DOCTYPE html>
<html>
<body>

<p><b>This text is bold</b></p>


<p><i>This text is italic</i></p>

20
Rajendra Prasad Joshi Sec : O1

<p>This is<sub> subscript</sub> and


<sup>superscript</sup></p>

</body>
</html>

Font tag

The <font> tag is an HTML element that was used


in older versions of HTML to specify the font, color,
and size of text within a web page.

<!DOCTYPE html>
<head>
<title>Document</title>

21
Rajendra Prasad Joshi Sec : O1

</head>
<body>
<font face="Cursive" size="6"> Did you see it ?
</font>
</body>
</html>

Inserting Image

<!DOCTYPE html>
<html>
<body>

<h2>Watch Out</h2>

<img
src="https://media.istockphoto.com/id/637696304/photo/
patan.jpg?s=612x612&w=is&k=20&c=wesFCvNKd9X0y
Q6jdGuAG-mqMICB1dI_B21Ac9PwWFY="
alt="W3Schools.com" >

</body>

22
Rajendra Prasad Joshi Sec : O1

</html>

Inserting Audio/ Video

<!DOCTYPE html>

23
Rajendra Prasad Joshi Sec : O1

<head>
<title>Document</title>
</head>
<body>
<video width="320" height="240" controls>
<source src="movie.mp4" type="video/mp4">
</video>
</body>
</html>

24
Rajendra Prasad Joshi Sec : O1

Hyperlink

<!DOCTYPE html>
<html>
<body>

<h1>HTML Links</h1>

<p><a href="https://www.youtube.com/">Visit
Youtube</a></p>

</body>
</html>

HTML Table

HTML tables are used to organize and display data


in rows and columns on a web page. They are

25
Rajendra Prasad Joshi Sec : O1

created using the <table>, <tr>, <th>, and <td>


elements.

<!DOCTYPE html>
<html>
<style>
table, th, td {
border:1px solid black;
}
</style>
<body>

<h2>A basic HTML table</h2>

<table style="width:100%">
<tr>
<th>Company</th>
<th>Contact</th>
<th>Country</th>
</tr>
<tr>
<td>Mega</td>
<td>Maria Anders</td>
<td>Nepal</td>

26
Rajendra Prasad Joshi Sec : O1

</tr>
<tr>
<td>Derex</td>
<td>Harry Bing</td>
<td>USA</td>
</tr>
</table>
</body>
</html>

LIST TAG

<!DOCTYPE html>
<html>
<body>

<h2>An ordered HTML list</h2>

27
Rajendra Prasad Joshi Sec : O1

<ol>
<li>Lamborghini</li>
<li>Ferrari</li>
<li>Mercedes-Benz</li>
</ol>

</body>
</html>

<!DOCTYPE html>
<html>
<body>

<h2>An unordered HTML list</h2>

<ul>
<li>Coffee</li>
<li>Tea</li>

28
Rajendra Prasad Joshi Sec : O1

<li>Milk</li>
</ul>

</body>
</html>

HTML Form

HTML forms are used to collect user input on a web


page. They allow users to enter data such as text,
numbers, selections, and more, which can then be
submitted to a server for processing.

<!DOCTYPE html>
<html>
<body>

29
Rajendra Prasad Joshi Sec : O1

<h2>HTML Forms</h2>

<form action="/action_page.php">
<label for="fname">First name:</label><br>
<input type="text" id="fname" name="fname"
value="Elon"><br>
<label for="lname">Last name:</label><br>
<input type="text" id="lname" name="lname"
value="Musk"><br><br>
<input type="submit" value="Submit">
</form>

</body>
</html>

30
Rajendra Prasad Joshi Sec : O1

CSS

CSS, which stands for Cascading Style Sheets, is a


style sheet language used to define the presentation
and layout of HTML (or XML) documents. It allows
web developers to control the appearance of web
pages, including aspects such as colors, fonts,
spacing, and positioning.

CSS is used to separate the presentation (visual


style) of a web page from its structure (HTML
content) and behavior (JavaScript functionality). By
using CSS, web developers can create consistent,
visually appealing designs across multiple web pages
and devices without having to apply styling directly
to HTML elements.

<!DOCTYPE html>
<html>
<body>

<h1 style="color:blue;">A Blue Heading</h1>

<p style="color:red;">A red paragraph.</p>

31
Rajendra Prasad Joshi Sec : O1

</body>
</html>

<!DOCTYPE html>
<html>
<head>
<style>
body {background-color: black;}
h1 {color: yellow;}
p {color: red;}
</style>
</head>
<body>

<h1>This is a heading</h1>
<p>This is a paragraph.</p>

</body>
</html>

32
Rajendra Prasad Joshi Sec : O1

style.css
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="styles.css">
</head> body {
background-color: powderblue;
<body> }
h1 {
color: blue;
<h1>Using External CSS</h1> }
p{
<p>MRX</p> color: red;
}

</body>
</html>

style.css

33
Rajendra Prasad Joshi Sec : O1

C programming

"C" is a general-purpose, procedural programming language


originally developed by Dennis Ritchie at Bell Labs in the
early 1970s. It was designed as a successor to the B
programming language and was created primarily for system
programming tasks such as writing operating systems. C has
had a profound impact on the field of computer science and
software development and remains one of the most widely
used programming languages to this day.

C is known for its efficiency, flexibility, and close-to-the-


hardware nature, making it suitable for developing low-level
systems software as well as high-level application software.
Its syntax is relatively simple and concise, yet powerful,
allowing developers to write compact and fast code.

One of the key features of C is its ability to manipulate


memory directly through pointers, which gives programmers
precise control over system resources but also introduces
the potential for errors such as memory leaks and
segmentation faults.

34
Rajendra Prasad Joshi Sec : O1

Over the years, C has influenced many other programming


languages, including C++, Objective-C, and even languages
like Java and Python. It serves as the foundation for many
modern operating systems, including Unix, Linux, and
Windows.

Despite its age, C remains popular in various domains,


including embedded systems, game development, and
system programming, where performance and control are
paramount. Its widespread use and enduring relevance make
it an essential language for any aspiring programmer to
learn.

Simple Program

1. //First C program
#include <stdio.h>

int main() {
printf("Hello World!");
printf("\n***Coded By:Rajendra Prasad Joshi***");
return 0;
}
Output:

35
Rajendra Prasad Joshi Sec : O1

2. // WAP to add two numbers


#include <stdio.h>

int main() {
double num1, num2, sum;
printf("Enter first number: ");
scanf("%lf", &num1);
printf("Enter second number: ");
scanf("%lf", &num2);
sum = num1 + num2;
printf("Sum = %.2lf\n", sum);
printf("\n***Coded By:Rajendra Prasad Joshi***");
return 0;
}

Output:

3. //WAP to find area and circumference of circle


#include <stdio.h>

int main() {

36
Rajendra Prasad Joshi Sec : O1

double radius, area, circumference;


const double PI = 3.14159;

printf("Enter the radius of the circle: ");


scanf("%lf", &radius);

area = PI * radius * radius;


circumference = 2 * PI * radius;

printf("Area of the circle: %.2lf\n", area);


printf("Circumference of the circle: %.2lf\n",
circumference);
printf("\n***Coded By:Rajendra Prasad Joshi***");
return 0;
}

Output:

4. //WAP to find area of rectangle


#include <stdio.h>

int main() {
double length, width, area;

37
Rajendra Prasad Joshi Sec : O1

printf("Enter the length of the rectangle: ");


scanf("%lf", &length);

printf("Enter the width of the rectangle: ");


scanf("%lf", &width);
area = length * width;
printf("Area of the rectangle: %.2lf\n", area);
printf("\n***Coded By:Rajendra Prasad Joshi***");

return 0;
}

Output:

5. // WAP to swap two numbers


#include <stdio.h>

int main() {
int a, b, temp;
printf("Enter two integers: ");
scanf("%d %d", &a, &b);
printf("Before swapping: a = %d, b = %d\n", a, b);

38
Rajendra Prasad Joshi Sec : O1

temp = a;
a = b;
b = temp;
printf("After swapping: a = %d, b = %d\n", a, b);
printf("\n***Coded By:Rajendra Prasad Joshi***");
return 0;
}

Output:

6. //WAP to find simple interst


#include <stdio.h>

int main() {
double principal, rate, time, simple_interest;

printf("Enter principal amount: ");


scanf("%lf", &principal);

printf("Enter rate of interest (per year): ");


scanf("%lf", &rate);

printf("Enter time period (in years): ");

39
Rajendra Prasad Joshi Sec : O1

scanf("%lf", &time);

simple_interest = (principal * rate * time) / 100;


printf("Simple interest = %.2lf\n", simple_interest);
printf("\n***Coded By:Rajendra Prasad Joshi***");
return 0;
}
Output:

7. //WAP to find area of triangle


#include <stdio.h>

int main() {
double base, height, area;

printf("Enter the base of the triangle: ");


scanf("%lf", &base);

printf("Enter the height of the triangle: ");


scanf("%lf", &height);

area = 0.5 * base * height;


printf("Area of the triangle: %.2lf\n", area);
printf("\n***Coded By:Rajendra Prasad Joshi***");

return 0;

40
Rajendra Prasad Joshi Sec : O1

Output:

I/O function in C

In C programming, input and output (I/O) functions are


fundamental for interacting with users, reading from or
writing to files, and communicating with external devices.
These functions are primarily part of the Standard
Input/Output Library, defined in the <stdio.h> header file.
They are: printf(), scanf(), putchar(), getchat(), fputs(),
fgets(),etc.

1. //Use of printf() and scanf() functions


#include <stdio.h>

int main() {
int num;
printf("Enter an integer: ");
scanf("%d", &num);

41
Rajendra Prasad Joshi Sec : O1

printf("You entered: %d\n", num);


printf("\n***Coded By:Rajendra Prasad Joshi***");
return 0;
}
Output:

2. // use of fputs() and fgets() functions in string


#include <stdio.h>

int main() {
char str[100];
printf("Enter a string: ");
fgets(str, sizeof(str), stdin);
printf("You entered: ");
fputs(str, stdout);
printf("\n***Coded By:Rajendra Prasad Joshi***");
return 0;
}

output:

42
Rajendra Prasad Joshi Sec : O1

3. // USing fetchar() and putchar() functions


#include <stdio.h>

int main() {
char ch;
printf("Enter a character: ");
ch = getchar();
printf("You entered: ");
putchar(ch);
printf("\n***Coded By:Rajendra Prasad Joshi***");
return 0;
}

Output:

IF
In C programming, the if statement is a fundamental control
structure used for decision-making. It allows you to execute

43
Rajendra Prasad Joshi Sec : O1

a block of code conditionally based on the evaluation of a


boolean expression.

1. //WAP to find an integer is even or odd


#include <stdio.h>

int main() {
int num;

printf("Enter an integer: ");


scanf("%d", &num);
if (num % 2 == 0) {
printf("%d is even.\n", num);
}
if (num % 2 != 0) {
printf("%d is odd.\n", num);
}
printf("\n***Coded By:Rajendra Prasad Joshi***");
return 0;
}

Output:

44
Rajendra Prasad Joshi Sec : O1

If … else statement
In C programming, the if-else statement is a powerful control
structure that allows you to execute different blocks of code
based on the evaluation of a boolean expression.

1. //WAP to determines whether a number is positive or


negative.
#include <stdio.h>

int main() {
int num;

printf("Enter a number: ");


scanf("%d", &num);

if (num >= 0) {
printf("%d is a positive number.\n", num);
} else {
printf("%d is a negative number.\n", num);
}
printf("\n***Coded By:Rajendra Prasad Joshi***");
return 0;
}
Output:

45
Rajendra Prasad Joshi Sec : O1

2. //WAP to find greatest among two numbers


#include <stdio.h>

int main() {
int num1, num2;

printf("Enter two numbers: ");


scanf("%d%d", &num1, &num2);

if (num1 >= num2) {


printf("%d is a greater.\n", num1);
} else {
printf("%d is a greater.\n", num2);
}
printf("\n***Coded By:Rajendra Prasad Joshi***");
return 0;
}

output:

46
Rajendra Prasad Joshi Sec : O1

3. //WAP to check wheatet a person is eligible for voting or


not
#include <stdio.h>

int main() {
int age;

printf("Enter your age:");


scanf("%d",&age);

if(age >= 18)


printf("You are eligible for voting");
else
printf("Come When you reach 18!!!");
printf("\n***Coded By:Rajendra Prasad Joshi***");
return 0;
}

Output:

If…else if statement

In C programming, the if-else if-else statement is used when


you have multiple conditions to evaluate sequentially. It

47
Rajendra Prasad Joshi Sec : O1

allows you to choose one of several blocks of code to


execute based on the outcome of multiple conditions.

1. //WAP to find smallest among three numbers.


#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("Smallest number: %d\n", num1);
} else if (num2 <= num1 && num2 <= num3) {
printf("Smallest number: %d\n", num2);
} else {
printf("Smallest number: %d\n", num3);
}

return 0;
}

Output:

48
Rajendra Prasad Joshi Sec : O1

2.//WAP to determine the sign of a integer.


#include <stdio.h>

int main() {
int num;

printf("Enter a number: ");


scanf("%d", &num);

if (num > 0) {
printf("Positive number\n");
} else if (num < 0) {
printf("Negative number\n");
} else {
printf("Zero\n");
}
printf("\n***Coded By:Rajendra Prasad Joshi***");
return 0;
}

Output:

49
Rajendra Prasad Joshi Sec : O1

3.//WAP to determine age group.


#include <stdio.h>

int main() {
int age;
printf("Enter your age: ");
scanf("%d", &age);

if (age >= 0 && age <= 12)


printf("Child\n");
else if (age >= 13 && age <= 19)
printf("Teenager\n");
else if (age >= 20 && age <= 59)
printf("Adult\n");
else if (age >= 60)
printf("Senior Citizen\n");
else
printf("Invalid age\n");
printf("\n***Coded By:Rajendra Prasad Joshi***");

return 0;
}

output:

50
Rajendra Prasad Joshi Sec : O1

Nested if…else statement

In C programming, a nested if-else statement refers to the


situation where one if-else statement is nested within
another. This allows for more complex decision-making logic,
where certain conditions need to be evaluated only if the
outer condition is true.

1. #include <stdio.h>

int main() {
int age;
char gender;

printf("Enter your age: ");


scanf("%d", &age);

printf("Enter your gender (M/F): ");

51
Rajendra Prasad Joshi Sec : O1

scanf(" %c", &gender);

if (age >= 18) {


if (gender == 'M') {
printf("You are a man.\n");
} else if (gender == 'F') {
printf("You are a woman.\n");
} else {
printf("Invalid gender.\n");
}
} else {
printf("You are not an adult yet.\n");
}
printf("\n***Coded By:Rajendra Prasad Joshi***");
return 0;
}

output:

Switch case
In C programming, the switch statement provides a way to
control flow based on the value of a variable or expression.
It's an alternative to using multiple if-else statements when

52
Rajendra Prasad Joshi Sec : O1

you have multiple conditions to evaluate against the same


variable.

1. WAP checks if a character entered by the user is a


vowel or a consonant.
#include <stdio.h>

int main() {
char ch;
printf("Enter a character: ");
scanf(" %c", &ch);

switch(ch) {
case 'a':
case 'e':
case 'i':
case 'o':
case 'u':
case 'A':
case 'E':
case 'I':
case 'O':
case 'U':
printf("%c is a vowel.\n", ch);
break;
default:
printf("%c is a consonant.\n", ch);
}

53
Rajendra Prasad Joshi Sec : O1

printf("\n***Coded By:Rajendra Prasad Joshi***");


return 0;
}

output:

2. //WAP to make simple calculator


#include <stdio.h>

int main() {
char operator;
double num1, num2, result;

printf("Enter an operator (+, -, *, /): ");


scanf(" %c", &operator);

printf("Enter two numbers: ");


scanf("%lf %lf", &num1, &num2);

switch(operator) {
case '+':
result = num1 + num2;

54
Rajendra Prasad Joshi Sec : O1

printf("Result: %.2lf\n", result);


break;
case '-':
result = num1 - num2;
printf("Result: %.2lf\n", result);
break;
case '*':
result = num1 * num2;
printf("Result: %.2lf\n", result);
break;
case '/':
if (num2 != 0) {
result = num1 / num2;
printf("Result: %.2lf\n", result);
} else {
printf("Error: Division by zero\n");
}
break;
default:
printf("Invalid operator\n");
}
printf("\n***Coded By:Rajendra Prasad Joshi***");
return 0;
}

Output:

55
Rajendra Prasad Joshi Sec : O1

3. // WAP to print Day of a week


#include <stdio.h>

int main() {
int day;
printf("Enter a number (1-7): ");
scanf("%d", &day);

switch(day) {
case 1:
printf("Sunday\n");
break;
case 2:
printf("Monday\n");
break;
case 3:
printf("Tuesday\n");
break;
case 4:
printf("Wednesday\n");
break;
case 5:
printf("Thursday\n");

56
Rajendra Prasad Joshi Sec : O1

break;
case 6:
printf("Friday\n");
break;
case 7:
printf("Saturday\n");
break;
default:
printf("Invalid input\n");
}
printf("\n***Coded By:Rajendra Prasad Joshi***");
return 0;
Output:
}

output:

FOR loop

In C programming, the for loop is a control flow statement


used to execute a block of code repeatedly for a fixed
number of times. It's particularly useful when you know the
exact number of iterations you want to perform.

1. //WAP to program to print from 1 to 5


#include <stdio.h>

int main() {

57
Rajendra Prasad Joshi Sec : O1

printf("Numbers from 1 to 5:\n");


for (int i = 1; i <= 5; ++i) {
printf("%d\n", i);
}
printf("\n***Coded By:Rajendra Prasad Joshi***");
return 0;
Output:
}

2.//WAP to find Factorial of number


#include <stdio.h>

int main() {
int num;
int factorial = 1;

printf("Enter a positive integer: ");


scanf("%d", &num);

for (int i = 1; i <= num; ++i) {


factorial *= i;
}
printf("Factorial of %d = %d\n", num, factorial);
printf("\n***Coded By:Rajendra Prasad Joshi***");
return 0;
}

58
Rajendra Prasad Joshi Sec : O1

output:

3.//WAP print multiplication table .


#include <stdio.h>

int main() {
int num;
printf("Enter a number: ");
scanf("%d", &num);

printf("Multiplication table of %d:\n", num);


for (int i = 1; i <= 10; ++i) {
printf("%d x %d = %d\n", num, i, num * i); }
printf("\n***Coded By:Rajendra Prasad Joshi***");
return 0;
}

output:

59
Rajendra Prasad Joshi Sec : O1

While loop

In C programming, the while loop is a control flow statement


that repeatedly executes a block of code as long as a
specified condition is true. It's useful when you want to loop
until a certain condition is no longer met.

1. //WAP to countdown from 5 to 1.


#include <stdio.h>

int main() {
int count = 5;
printf("Countdown from 5 to 1:\n");
while (count >= 1) {
printf("%d\n", count);
count--;
}

60
Rajendra Prasad Joshi Sec : O1

printf("Blast off!\n");
printf("\n***Coded By:Rajendra Prasad Joshi***");
return 0;
}

Output:

2. //WAP to find sum of numbers from 1 to 100.


#include <stdio.h>

int main() {
int sum = 0, num = 1;

while (num <= 100) {


sum += num;
num++;
}
printf("Sum of numbers from 1 to 100: %d\n", sum);
printf("\n***Coded By:Rajendra Prasad Joshi***");
return 0;
}

61
Rajendra Prasad Joshi Sec : O1

Output:

3. //WAP to print even numbers from 1 to 20.


#include <stdio.h>

int main() {
int num = 2;

printf("Even numbers from 1 to 20:\n");


while (num <= 20) {
printf("%d\n", num);
num += 2;
}
printf("\n***Coded By:Rajendra Prasad Joshi***");
return 0;
}

Output:

62
Rajendra Prasad Joshi Sec : O1

Do…while loop

In C programming, the do-while loop is a control flow


statement that executes a block of code at least once, and
then repeatedly executes the block as long as a specified
condition is true. Unlike the while loop, the do-while loop
evaluates its condition after the block of code has been
executed, ensuring that the block of code is executed at
least once.

1.//WAP to find sum of numbers from 1 to 50.


#include <stdio.h>

int main() {
int sum = 0, num = 1;
do {
sum += num;
num++;
} while (num <= 50);

63
Rajendra Prasad Joshi Sec : O1

printf("Sum of numbers from 1 to 50: %d\n", sum);


printf("\n***Coded By:Rajendra Prasad Joshi***");
return 0;
}

output:

2.//WAP to print odd number from 1 to 10.


#include <stdio.h>

int main() {
int num = 1;

printf("Odd numbers from 1 to 10:\n");


do {
printf("%d\n", num);
num += 2;
} while (num <= 10);
printf("\n***Coded By:Rajendra Prasad Joshi***");
return 0;
Output:
}

64
Rajendra Prasad Joshi Sec : O1

3. //WAP to find factorial


#include <stdio.h>

int main() {
int num, factorial = 1, i = 1;

printf("Enter a positive integer: ");


scanf("%d", &num);

do {
factorial *= i;
i++;
} while (i <= num);

printf("Factorial of %d = %d\n", num, factorial);


printf("\n***Coded By:Rajendra Prasad Joshi***");
return 0;
}

output:

BREAK STATEMENT

65
Rajendra Prasad Joshi Sec : O1

In C programming, the break statement is used to exit a


loop prematurely. It can be used within for, while, or do-
while loops, as well as within switch statements. When the
break statement is encountered inside a loop or switch
statement, the control flow immediately exits the loop or
switch block, and program execution continues with the
statement following the loop or switch block.

1. //Demonstration of Break statement in loop


#include <stdio.h>

int main() {
for (int i = 1; i <= 10; ++i) {
printf("%d\n", i);
if (i == 5) {
break;
}
}
printf("\n***Coded By:Rajendra Prasad Joshi***");
return 0;
}

output:

66
Rajendra Prasad Joshi Sec : O1

Continue STATEMENT

In C programming, the continue statement is used within


loops to skip the rest of the code in the current iteration
and proceed to the next iteration of the loop. When the
continue statement is encountered, the control flow
immediately jumps back to the beginning of the loop,
skipping any remaining statements within the loop body.

1.//Skip odd number


#include <stdio.h>

int main() {
for (int i = 1; i <= 10; ++i) {
if (i % 2 != 0) {
continue;
}
printf("%d\n", i);
}
printf("\n***Coded By:Rajendra Prasad Joshi***");
return 0;
}

Output:

67
Rajendra Prasad Joshi Sec : O1

Go to statement

In C programming, the goto statement is used to transfer


control unconditionally to another labeled statement within
the same function. While goto can be a powerful tool, its
use is generally discouraged because it can make code
harder to understand and maintain, and it can lead to
unstructured and error-prone code.

#include <stdio.h>

int main() {
int num = 1;

start:
printf("Current value of num: %d\n", num);
num++;

if (num <= 5) {
goto start;

68
Rajendra Prasad Joshi Sec : O1

}
printf("\n***Coded By:Rajendra Prasad Joshi***");
return 0;
}

output:

ARRAY

In C programming, an array is a collection of elements of


the same data type, stored in contiguous memory locations.
Each element in the array can be accessed using an index,
which represents its position within the array. Arrays provide
a convenient way to store and manipulate multiple values of
the same type.

1.//Sum of array element


#include <stdio.h>

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

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

69
Rajendra Prasad Joshi Sec : O1

sum += numbers[i];
}

printf("Sum of array elements: %d\n", sum);


printf("\n***Coded By:Rajendra Prasad Joshi***");
return 0;
}

output:

2//WAP to Find Maximum Element in Array:


#include <stdio.h>

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

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


if (numbers[i] > max) {
max = numbers[i];
}
}
printf("Maximum element in array: %d\n", max);
printf("\n***Coded By:Rajendra Prasad Joshi***");
return 0;

70
Rajendra Prasad Joshi Sec : O1

output

3. //print reverse of array


#include <stdio.h>

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

printf("Array in reverse order: ");


for (int i = 4; i >= 0; --i) {
printf("%d ", numbers[i]);
}
printf("\n");
printf("\n***Coded By:Rajendra Prasad Joshi***");
return 0;
}

output:

4. //Check even number in arary.

71
Rajendra Prasad Joshi Sec : O1

#include <stdio.h>

int main() {
int numbers[] = {10, 21, 30, 45, 50};

printf("Even numbers in array: ");


for (int i = 0; i < 5; ++i) {
if (numbers[i] % 2 == 0) {
printf("%d ", numbers[i]);
}
}
printf("\n***Coded By:Rajendra Prasad Joshi***");

return 0;
}

output:

5. //Calculate average of array element


#include <stdio.h>

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

72
Rajendra Prasad Joshi Sec : O1

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


sum += numbers[i];
}

float average = (float)sum / 5;


printf("Average of array elements: %.2f\n", average);
printf("\n***Coded By:Rajendra Prasad Joshi***");
return 0;
}
output:

6. //Reverse string
#include <stdio.h>
#include <string.h>

int main() {
char str[] = "Hello";
int length = strlen(str);

printf("Original string: %s\n", str);

for (int i = 0; i < length / 2; ++i) {


char temp = str[i]; Output:

str[i] = str[length - i - 1];


str[length - i - 1] = temp;
}

73
Rajendra Prasad Joshi Sec : O1

printf("Reversed string: %s\n", str);


printf("\n***Coded By:Rajendra Prasad Joshi***");
return 0;
}

7. //count occurances of an element


#include <stdio.h>

int main() {
int numbers[] = {10, 20, 30, 20, 40, 20, 50};
int target = 20;
int count = 0;

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


Output:
if (numbers[i] == target) {
count++;
}
}
printf("Number of occurrences of %d: %d\n", target, count);
printf("\n***Coded By:Rajendra Prasad Joshi***");

return 0;
}

74
Rajendra Prasad Joshi Sec : O1

String Function

In C programming, strings are typically represented as


arrays of characters terminated by a null character '\0',
which marks the end of the string. C does not have a built-
in string data type like some other programming languages,
so strings are commonly manipulated using arrays of
characters along with various string manipulation functions.

1. //String length
#include <stdio.h>
#include <string.h> Output:

int main() {
char str[] = "Hello, World!";
int length = strlen(str);
printf("Length of the string: %d\n", length);
printf("\n***Coded By:Rajendra Prasad Joshi***");
return 0;
}

2. // WAP to copy string


Output:
#include <stdio.h>
#include <string.h>

75
Rajendra Prasad Joshi Sec : O1

int main() {
char source[] = "Hello";
char destination[20];
strcpy(destination, source);
printf("Copied string: %s\n", destination);
printf("\n***Coded By:Rajendra Prasad Joshi***");
return 0;
}

3. //string concatenation output:


#include <stdio.h>
#include <string.h>

int main() {
char str1[] = "Hello";
char str2[] = " World!";
strcat(str1, str2);
printf("Concatenated string: %s\n",
str1);
printf("\n***Coded By:Rajendra
Prasad Joshi***");
return 0;
}

4. string comparison output:


#include <stdio.h>
#include <string.h>

76
Rajendra Prasad Joshi Sec : O1

int main() {
char str1[] = "Hello";
char str2[] = "Hello";
if (strcmp(str1, str2) ==
0) {
printf("Strings are
equal.\n");
} else {
printf("Strings are
not equal.\n");
}
printf("\n***Coded
By:Rajendra Prasad
Joshi***");
return 0;
}

5. // string upper/lower case conversion


#include <stdio.h>
#include <string.h>

int main() {
char str[] = "Hello, World!";
for (int i = 0; i < strlen(str); ++i) {
if (str[i] >= 'a' && str[i] <= 'z') {
str[i] -= 32; // Convert to uppercase
} else if (str[i] >= 'A' && str[i] <= 'Z') {
str[i] += 32; // Convert to lowercase

77
Rajendra Prasad Joshi Sec : O1

}
}
printf("Modified string: %s\n", str);
printf("\n***Coded By:Rajendra Prasad Joshi***");
return 0;
}

output:

//WAP that checks whether it contains a substring:


#include <stdio.h>
#include <string.h>
int main() {
char str[100];
char substring[100];

printf("Enter a string: ");


scanf("%s", str);

printf("Enter a substring to search for: ");


scanf("%s", substring);

if (strstr(str, substring) != NULL) {


printf("'%s' contains '%s'.\n", str, substring);
} else {
printf("'%s' does not contain '%s'.\n", str, substring); }

78
Rajendra Prasad Joshi Sec : O1

printf("\n***Coded By:Rajendra Prasad Joshi***");


return 0;
}
output:

7. //WAP to count characters in string Output:


#include <stdio.h>
#include <string.h>

int main() {
char str[20] ;
int count = 0;
printf("Enter a string: ");
scanf("%s",&str);

for (int i = 0; i < strlen(str); ++i)


{
if (str[i] != ' ') {
count++;
}
}
printf("Number of characters in
'%s': %d\n", str, count);
printf("\n***Coded By:Rajendra

79
Rajendra Prasad Joshi Sec : O1

Prasad Joshi***");
return 0;
}

80

You might also like