Professional Documents
Culture Documents
SUBMITTED BY
MD.TOWHIDUL ISLAM
STUDENT_ID: 200913
ELECTRONICS AND COMMUNICATION ENGINEERING DISCIPLINE
Problem 1: Perform the following operations on an integer
array of 10 elements. Accept the values from the user.
a. Sort an array in ascending order.
Solution:
#include<stdio.h>
int main()
{
int i, j, a, num[50];
if(num[i]>num[j])
{
a=num[i];
num[i]=num[j];
num[j]=a;
}
}
}
printf("Sorted elements of array in ascending order: ");
for(i=0;i<10;i++)
{
printf(" %d", num[i]);
}
return 0;
Solution:
#include<stdio.h>
int main()
{
int i, num[50], sum=0;
for(i=0;i<10;i++)
{
scanf("%d", &num[i]);
}
for(i=0;i<10;i++)
{
if(num[i]%2!=0)
sum= sum + num[i];
}
return 0;
}
Solution:
#include<stdio.h>
int main()
{
int i, numbers[50], a=0;
for(i=0; i<10; i++)
{
scanf("%d", &numbers[i]);
}
for(i=0; i<10; i++)
{
if(numbers[i]%2==0)
a=a+1;
}
printf("The number of even values stored in an array : %d", a);
return 0;
}
Problem 2: Write a program to evaluate the net salary of an
employee given the following constraints:
Solution:
#include<stdio.h>
int main()
{
float salary, da, hra, ta, others, pf, it, net;
printf("Basic Salary = ");
scanf("%f", &salary);
printf("TA = ");
scanf("%f", &ta);
printf("HRA = ");
scanf("%f", &hra);
printf("Others = ");
scanf("%f", &others);
da = (12.0*salary)/100;
pf = (14.0*salary)/100;
it = (15.0*salary)/100;
return 0;
}
Problem 3: Write a program which prints the ASCII values of
the characters ‘A’ and ‘b’.
Solution:
#include<stdio.h>
int main()
{
printf("the ASCII value of the character A = %d\n and ", 'A');
printf("the ASCII value of the character b = %d\n ", 'b');
return 0;
}
Solution:
Solution:
#include<stdio.h>
int main()
{
int a[50], n, i;
scanf("%d", &n);
for(i=0 ; i<n; i++)
{
scanf("%d", &a[i]);
}
printf("Reverse Array: ");
for(i=n-1; i>=0; i--)
{
printf("%d ", a[i]);
}
return 0;
}
Solution:
#include<stdio.h>
int main()
{
int a[100], i, n;
return 0;
}
Solution:
#include<stdio.h>
int fac(int n)
{
if(n==1)
return 1;
else
return (n*fac(n-1));
}
int main()
{
int n;
scanf("%d", &n);
printf("factorial = %d", fac(n) );
return 0;
}
Solution:
Problem 9: Write a C program to check whether a number is
even or odd using functions.
Solution:
Problem 10: Write a C program to read an amount (integer
value) and break the amount into smallest possible number of
bank notes.
Solution: