Tally Notes
Tally Notes
AN
Assignment
Report
On
PROGRAMING IN “C”
Submitted in partial fulfilment of the requirements for
the award of diploma
Guided By
Submitted by:
Page 1
Programming in ‘C’ PGDCA (2023-24)
CERTIFICATE OF APPROVAL
Page 2
Programming in ‘C’ PGDCA (2023-24)
CERTIFICATE OF GUIDE
Page 3
Programming in ‘C’ PGDCA (2023-24)
DECLARATION/SELF CERTIFICATE
Page 4
Programming in ‘C’ PGDCA (2023-24)
ACKNOWLEDGEMENT
Page 5
Programming in ‘C’ PGDCA (2023-24)
INDEX
* 1 1
** 22 12
* * * 333 123
* * * * * 55555 12345
Page 6
Programming in ‘C’ PGDCA (2023-24)
29 Write a program in c to reverse a string without using library function .Write user
defined function.
30 Write a program in c to calculate length of string without using string handling
function.
Program- 1
Page 7
Programming in ‘C’ PGDCA (2023-24)
Source code :
#include<stdio.h>
#include<conio.h> void
main()
else
getch();
Program- 2
Source code :
#include<stdio.h>
Page 8
Programming in ‘C’ PGDCA (2023-24)
a="); scanf("%d",&a);
scanf("%d",&c);
else
getch();
Program- 3
Write a program in c to swap 2 numbers using 3rd variable.
Source code :
#include<stdio.h>
#include<conio.h> void
main()
Page 9
Programming in ‘C’ PGDCA (2023-24)
scanf("%d",&a);
getch();
Program- 4
Source code :
#include<stdio.h>
#include<conio.h> void
main()
Page 10
Programming in ‘C’ PGDCA (2023-24)
printf("***Before Swapping***\n");
scanf("%d",&a);
scanf("%d",&b);
printf("\n***After Swapping***\n");
getch();
Program- 5(A)
Source code :
Page 11
Programming in ‘C’ PGDCA (2023-24)
#include<stdio.h>
#include<conio.h> void
main()
for(i=1;i<=5;i++)
for(j=1;j<=i;j++)
{ printf("*
");
printf("\n");
getch();
Program- 5(B)
Page 12
Programming in ‘C’ PGDCA (2023-24)
Source code :
#include<stdio.h>
#include<conio.h> void
main()
for(i=1;i<=5;i++)
for(j=1;j<=i;j++)
printf(" %d",i);
printf("\n");
getch();
---------------------------------------------------------Output:- -----------------------------------------------------
Page 13
Programming in ‘C’ PGDCA (2023-24)
Program- 5(C)
Source code :
#include<stdio.h>
#include<conio.h> void
main()
for(j=1;j<=i;j++)
printf(" %d",j);
printf("\n");
getch();
Page 14
Programming in ‘C’ PGDCA (2023-24)
Program- 5(D)
Source code :
#include<stdio.h>
for(j=i;j<=5;j++)
printf(" ");
for(s=1;s<=i;s++)
{ printf("* ");
printf("\n");
getch();
Page 15
Programming in ‘C’ PGDCA (2023-24)
------------------------
---------------------
Output:-
------------------------
-------------------
Page 16
Programming in ‘C’ PGDCA (2023-24)
Page 17
Programming in ‘C’ PGDCA (2023-24)
Program- 5(E)
Source code :
#include<stdio.h>
#include<conio.h> void
main()
for(j=i;j<=5;j++)
printf(" ");
for(s=1;s<=i;s++)
printf("%d ",i);
printf("\n");
getch();
Page 18
Programming in ‘C’ PGDCA (2023-24)
Program 6
Source code :
#include<stdio.h>
#include<conio.h> void
main()
",b);
for(i=1;i<=n-2;i++)
c=a+b;
printf("%d ",c);
a=b; b=c;
getch();
-----------------------
----------------------
Output:-
-----------------------
---------------------
Page 19
Programming in ‘C’ PGDCA (2023-24)
Page 20
Programming in ‘C’ PGDCA (2023-24)
Program 7
Source code :
#include<stdio.h>
#include<conio.h> void
main()
scanf("%d",&n); a=0;
printf("%d ",c);
for(i=1;i<=n-3;i++)
d=a+b+c;
printf("%d ",d);
getch();
--------------------
--------------------
----- Output:-
--------------------
--------------------
----
Page 21
Programming in ‘C’ PGDCA (2022-23)
Program 8
#include<conio.h> void
main()
scanf("%d",&n); printf("----Result----");
for(i=n;i>=1;i--)
fact=fact*i;
--------------------
--------------------
----- Output:-
--------------------
--------------------
----
Page 22
Programming in ‘C’ PGDCA (2023-24)
Program 9
#include<conio.h> void
main()
scanf("%d",&n); printf("\
n----RESULT----\n");
for(i=2;i<=n/2;i++)
if(n%i==0)
flag=1; break;
if(flag==0)
Page 23
Programming in ‘C’ PGDCA (2022-23)
else
getch();
Page 24
Programming in ‘C’ PGDCA (2023-24)
---------------------
--------------------
---- Output:-
--------------------
--------------------
----
Page 25
Programming in ‘C’ PGDCA (2023-24)
Program- 10
#include<conio.h> void
main()
while(n!=0)
r=n%10;
sum=sum+r*r*r;
n=n/10;
printf("\n----RESULT----"); if(sum==num)
else
getch();
Page 26
Programming in ‘C’ PGDCA (2023-24)
---------------------
--------------------
---- Output:-
--------------------
--------------------
----
Page 27
Programming in ‘C’ PGDCA (2023-24)
Program- 11
for(i=0;i<n;i++)
scanf("%d",&arr[i]);
for(j=0;j<=n-1;j++)
Page 28
Programming in ‘C’ PGDCA (2023-24)
printf("%d ",arr[j]);
} printf("\n-------------------------\n");
printf("enter any no. of search= ");
scanf("%d",&k);
for(i=0;i<n;i++)
if(arr[i]==k)
flag=0;
} else
{
getch();
Page 29
Programming in ‘C’ PGDCA (2023-24)
---------------------
--------------------
---- Output:-
--------------------
--------------------
----
Page 30
Programming in ‘C’ PGDCA (2023-24)
Program- 12
Source code :
#include<stdio.h>
#include<conio.h> void
main()
for(i=0;i<n;i++)
scanf("%d",&arr[i]);
for(j=0;j<=n-1;j++)
printf("%d ",arr[j]);
} printf("\n-------------------------\n");
for(i=0;i<n;i++)
for(j=0;j<n-i-1;j++)
Page 31
Programming in ‘C’ PGDCA (2023-24)
if(arr[j]>arr[j+1])
temp=arr[j];
arr[j]=arr[j+1];
arr[j+1]=temp;
printf("%d ",arr[i]);
getch();
---------------------
--------------------
---- Output:-
--------------------
--------------------
----
Page 32
Programming in ‘C’ PGDCA (2023-24)
Program- 13
Source code :
#include<stdio.h>
#include<conio.h> void
main()
for(d=0;d<n;d++)
scanf("%d",&fst[c][d]);
n"); for(c=0;c<m;c++)
for(d=0;d<n;d++)
scanf("%d",&sec[c][d]);
Page 33
Programming in ‘C’ PGDCA (2023-24)
} printf("-----------------------------\n");
for(c=0;c<m;c++)
for(d=0;d<n;d++)
sum[c][d]=fst[c][d]+sec[c][d]; printf("%d\t",sum[c]
[d]);
printf("\n");
getch();
---------------------
--------------------
---- Output:-
--------------------
--------------------
----
Page 34
Programming in ‘C’ PGDCA (2023-24)
Page 35
Programming in ‘C’ PGDCA (2023-24)
Program 14
Source code :
#include<stdio.h>
#include<conio.h> void
main()
for(c=0;c<m;c++)
for(d=0;d<n;d++)
scanf("%d",&fst[c][d]);
for(c=0;c<m;c++)
for(d=0;d<n;d++)
scanf("%d",&sec[c][d]);
Page 36
Programming in ‘C’ PGDCA (2023-24)
} } printf("-----------------------------\
n");
for(c=0;c<m;c++)
for(d=0;d<n;d++)
sub[c][d]=fst[c][d]-sec[c][d]; printf("%d\t",sub[c]
[d]);
printf("\n");
getch();
Page 37
Programming in ‘C’ PGDCA (2023-24)
----------------------
----------------------
- Output:-
----------------------
---------------------
P
r
o
g
r
a
m
1
5
Source code :
Page 38
Programming in ‘C’ PGDCA (2023-24)
#include<stdio.h>
#include<conio.h> void
main()
+)
for(d=0;d<n;d++)
scanf("%d",&fst[c][d]);
for(c=0;c<m;c++)
for(d=0;d<n;d++)
scanf("%d",&sec[c][d]);
} printf("-----------------------------\n");
for(c=0;c<m;c++)
for(d=0;d<n;d++)
Page 39
Programming in ‘C’ PGDCA (2023-24)
mult[c][d]=fst[c][d]*sec[c][d]; printf("%d\t",mult[c]
[d]);
printf("\n");
getch();
----------------------
----------------------
- Output:-
----------------------
----------------------
Program 16
to b.
Page 40
Programming in ‘C’ PGDCA (2023-24)
Source code :
#include<conio.h>
#include<stdio.h> #include<math.h>
main()
printf("\n ----------------------------------------------------------");
&b);
res=power(a,b);
printf(" ----------------------------------------------------------");
{ int
x;
x=pow(a,b);
return x;
Page 41
Programming in ‘C’ PGDCA (2023-24)
----------------------
----------------------
- Output:-
----------------------
----------------------
Page 42
Programming in ‘C’ PGDCA (2023-24)
Program 17
Source code :
#include<stdio.h>
#include<conio.h> void
main()
scanf("%d",&a);
printf("----------------");
case 1: printf("Sunday");
break;
case 2: printf("Monday");
break;
case 3: printf("Tuesday");
break;
case 4: printf("Wednesday");
break;
case 5: printf("Thursday");
break;
case 6: printf("Friday");
break;
Page 43
Programming in ‘C’ PGDCA (2023-24)
case 7: printf("Saturday");
break;
default:
getch();
----------------------
----------------------
- Output:-
----------------------
----------------------
Page 44
Programming in ‘C’ PGDCA (2023-24)
Program 18
Source code :
#include<conio.h>
#include<stdio.h> void
main()
printf("\n-----------------------------------------\n");
length=strlen(str1);
for(i=0;i<length;i++)
if(str1[i]!=str1[length-i-1])
flag=1;
Page 45
Programming in ‘C’ PGDCA (2023-24)
else
printf("%s is a PALINDROME",str1);
getch();
----------------------
----------------------
- Output:-
----------------------
----------------------
Page 46
Programming in ‘C’ PGDCA (2023-24)
Program 19
#include<stdio.h>
{ int
t;
t=*x;
*x=*y;
*y=t;
void main()
int num1,num2;
Page 47
Programming in ‘C’ PGDCA (2023-24)
scanf("%d",&num1); printf("\nEnter
scanf("%d",&num2);
num2 is : %d",num2);
getch(); clrscr();
----------------------
----------------------
- Output:-
----------------------
----------------------
Page 48
Programming in ‘C’ PGDCA (2023-24)
Program 20
#include<conio.h> void
swap(int,int); void
main()
int temp; temp=a; a=b; b=temp; printf("\n**** -- After swapping values in function :
-- **** \na=%d\nb=%d\n",a,b);
Page 49
Programming in ‘C’ PGDCA (2023-24)
----------------------
----------------------
- Output:-
----------------------
----------------------
Program 21
#include<conio.h> void
swap(int*,int*); void
main()
Page 50
Programming in ‘C’ PGDCA (2023-24)
*x=*y;
*y=temp;
----------------------
----------------------
- Output:-
----------------------
----------------------
P
r
o
g
r
a
m
-
2
2
Page 51
Programming in ‘C’ PGDCA (2023-24)
Source code :
#include<conio.h>
#include<stdio.h>
main()
scanf("%d",&num); fact=find_factorial(num);
Factorial of %d is : %d",num,fact);
getch();
int find_factorial(int n)
if(n==0)
return(1);
return(n*find_factorial(n-1));
Page 52
Programming in ‘C’ PGDCA (2023-24)
----------------------
----------------------
- Output:-
----------------------
----------------------
Page 53
Programming in ‘C’ PGDCA (2023-24)
Page 54
Programming in ‘C’ PGDCA (2023-24)
Program- 23
function.
Source code :
#include<stdio.h>
#include<conio.h> void
main()
printf("----------------------------"); printf("\n
l++;
getch();
Page 55
Programming in ‘C’ PGDCA (2023-24)
---------------------
---------------------
--- Output:-
---------------------
---------------------
--
Program- 24
Write a program in c to create a structure employee with data members (id, name,
salary) to store the id, name, salary and print values of Data members.
Source code :
#include<stdio.h>
#include<conio.h>
#include<string.h> struct
employee
char name[50];
salary;
};
main()
Page 56
Programming in ‘C’ PGDCA (2023-24)
e2.id=102; strcpy(e2.name,"Ramesh
Das"); e2.salary=25000;
printf("Emp1 id \t:%d",e2.id);
getch();
---------------------
---------------------
--- Output:-
---------------------
---------------------
--
Page 57
Programming in ‘C’ PGDCA (2023-24)
Program- 25
code :
#include<stdio.h>
#include<conio.h> void
main()
else
Page 58
Programming in ‘C’ PGDCA (2023-24)
getch();
---------------------
---------------------
--- Output:-
---------------------
---------------------
--
Program- 26
#include<conio.h> void
main()
printf("\n5. Modulus");
Page 59
Programming in ‘C’ PGDCA (2023-24)
printf("\n--------------------------");
scanf("%d",&a); printf("Enter
printf("--------------------------");
printf("--------------------------\n"); switch(c)
of Addition : ");
Multiplication : ");
break;
of Division : ");
break; case
5:
c=a%b;
break; default:
printf("%d",c); getch();
Page 60
Programming in ‘C’ PGDCA (2023-24)
---------------------
---------------------
--- Output:-
---------------------
---------------------
--
Program- 27
#include<conio.h> void
main()
Page 61
Programming in ‘C’ PGDCA (2023-24)
int n,rev=0,rem;
clrscr();
for(;n!=0;)
rem=n%10;
rev=rev*10+rem;
n=n/10;
no. = %d",rev);
getch();
---------------------
---------------------
--- Output:-
---------------------
---------------------
--
Page 62
Programming in ‘C’ PGDCA (2023-24)
Pr
o
gr
a
m
2
8
#include<conio.h> void
main()
an alphabet: ");
scanf("%c",&ch); printf("\
n------RESULT--------");
if(ch=='a'||ch=='e'||ch=='i'||ch=='o'||ch=='u')
printf("\nIt's a vowel");
else if(ch=='A'||ch=='E'||ch=='I'||ch=='O'||ch=='U')
printf("\nIt's a VOWEL");
else
printf("\nIt's a CONSONENT");
getch();
Page 63
Programming in ‘C’ PGDCA (2023-24)
---------------------
---------------------
--- Output:-
---------------------
---------------------
--
Page 64
Programming in ‘C’ PGDCA (2023-24)
Program-
Pr
o
gr
a
m
2
9
Write a program in c to reverse a string without using library function .Write user
defined function.
Source code :
#include<stdio.h>
#include<conio.h> void
main()
clrscr(); count=0;
scanf("%s",str);
printf("-------------------\n");
+)
count++;
for(i=count-1;i>=0;i--)
printf("%c",str[i]);
getch();
Page 65
Programming in ‘C’ PGDCA (2023-24)
---------------------
---------------------
--- Output:-
---------------------
---------------------
--
Page 66
Programming in ‘C’ PGDCA (2023-24)
Program-
30
Write a program in c to reverse a string without using library function .Write user
defined function.
Source code :
#include<stdio.h>
#include<conio.h> void
main()
printf("----------------------------"); printf("\n
l++;
getch();
Page 67
Programming in ‘C’ PGDCA (2023-24)
---------------------
---------------------
--- Output:-
---------------------
---------------------
--
Page 68