A Micro Project Report
on
Problem Solving using C Language
Submitted by
B MA SAI PAVAN (23471A05DD)
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING
NARASARAOPETA ENGINEERING COLLEGE: NARASARAOPET
(AUTONOMOUS)
Accredited by NAAC with A+ Grade and NBA under Tier-1
NIRF rank in the band of 201-300 and is an ISO 9001:2015 certified Approved by
AICTE, New Delhi, Permanently affiliated to JNTU Kakinada, Approved by AICTE,
Accredited by NBA and accredited ’A+’ grade by NAAC Narasaraopet-522601,
Palnadu(Dt.), Andhra Pradesh, India
2024-2025
NARASARAOPETA ENGINEERING COLLEGE: NARASARAOPET
(AUTONOMOUS)
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING
CERTIFICATE
This is to certify that B MA SAI PAVAN, Roll No: 23471A05DD, a Second Year
Student of the Department of Computer Science and Engineering, has completed the
Micro Project Satisfactorily in “Problem Solving using C Language" for the
Academic Year 2024-2025..
Project Co-Ordinator HEAD OF THE DEPARTMENT
Dr. Rama Krishna. Eluri, M.Tech., Ph.D. Dr. S. N. Tirumala Rao, M.Tech., Ph.D.
Asst. Professor Professor
INDEX
S.No Description
1. C Program to Read a number and displaying it's digits in words
C Program to the given triangles specifically their sides and print them in
the same style by their areas from smallest to the largest one.It is
2.
guaranteed that all the areas are different
C program generate the following output
ABCDEFGFEDCBA
ABCDEF FEDCBA
ABCDE EDCBA
ABCD DCBA
3.
ABC CBA
AB BA
A A
Read a Number and Displaying it's Digits in Words
AIM:
Write a C program to Read a Number and Displaying it's Digits in Words
#include<stdio.h>
#include<math.h>
int main()
int x,digit=0,num;
printf("Enter a number : ");
scanf("%d",&x);
num = (int) log10(x);
while(x!=0)
digit=(digit*10)+(x %10);
x=x/10;
num = num - ((int) log10(digit));
while(digit!=0)
switch(digit%10)
{
case 0:
printf("Zero ");
break;
case 1:
printf("One ");
break;
case 2:
printf("Two ");
break;
case 3:
printf("Three ");
break;
case 4:
printf("Four ");
break;
case 5:
printf("Five ");
break;
case 6:
printf("Six ");
break;
case 7:
printf("Seven ");
break;
case 8:
printf("Eight ");
break;
case 9:
printf("Nine ");
break;
digit=digit/10;
while(num)
printf("Zero ");
num--;
return 0;
Input:
Enter a Num : 312906
Output:
Three One Two Nine Zero Six
Sorting of Triangle Areas from Smallest to Largest
AIM :
C Program to the given triangles specifically their sides and print them in the same
style by their areas from smallest to the largest one. It is guaranteed that all the areas
are different
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
struct triangle
int a;
int b;
int c;
};
typedef struct triangle triangle;
double area(triangle tr) {
double p = (tr.a + tr.b + tr.c) / 2.0;
return sqrt(p * (p - tr.a) * (p - tr.b) * (p - tr.c));
int compare(const void *a, const void *b) {
triangle *t1 = (triangle*) a;
triangle *t2 = (triangle*) b;
double area1 = area(*t1);
double area2 = area(*t2);
if (area1 > area2) {
return 1;
} else if (area1 < area2) {
return -1;
} else {
return 0;
void sort_by_area(triangle* tr, int n) {
qsort(tr, n, sizeof(triangle), compare);
}
int main()
int n;
printf("Enter no of triangle sides");
scanf("%d", &n);
triangle *tr = malloc(n * sizeof(triangle));
for (int i = 0; i < n; i++) {
scanf("%d%d%d", &tr[i].a, &tr[i].b, &tr[i].c);
sort_by_area(tr, n);
for (int i = 0; i < n; i++) {
printf("After sorting: ");
printf("%d %d %d\n", tr[i].a, tr[i].b, tr[i].c);
return 0;
Input:
Enter no of triangle sides 3
5 12 13
7 24 25
345
Output:
After sorting: 3 4 5
After sorting: 5 12 13
After sorting: 7 24 25
To Print the given Pattern Format
AIM:
C Program to generate the following output
ABCDEFGFEDCBA
ABCDEF FEDCBA
ABCDE EDCBA
ABCD DCBA
ABC CBA
AB BA
A A
#include<stdio.h>
int main()
for(int i=0;i<=6;i++)
for(int j=65;j<=71-i;j++)
printf("%c ",j);
for(int k=0;k<(i*2)-1;k++)
{
printf(" ");
for(int l=71-i;l>=65;l--)
if(l!=71)
printf("%c ",l);
printf("\n");