0% found this document useful (0 votes)
12 views142 pages

Assignment 1

The document provides details of programming experiments performed by a student in C language. It lists 50 experiments conducted from December 2021 to February 2022 related to basic programming concepts like calculations, conditional statements, loops, functions, arrays etc. Each experiment lists the date of performance and checking along with any remarks. The programs cover concepts like calculators, conversions, finding averages, checking even/odd, greater of 3 numbers, area calculations etc.

Uploaded by

sdc
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views142 pages

Assignment 1

The document provides details of programming experiments performed by a student in C language. It lists 50 experiments conducted from December 2021 to February 2022 related to basic programming concepts like calculations, conditional statements, loops, functions, arrays etc. Each experiment lists the date of performance and checking along with any remarks. The programs cover concepts like calculators, conversions, finding averages, checking even/odd, greater of 3 numbers, area calculations etc.

Uploaded by

sdc
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 142

PROGRAMMING IN C

Faculty name : Mr. Sachin Garg Student name : HARISH GHASOLIA


Assistant Professor
I.T. Department Roll No.: 70

Group: O2

Semester: 1

Maharaja Agrasen Institute of Technology, PSP Area,


Sector – 22, Rohini, New Delhi – 110085

MAIT 1
INTRODUCTION TO PROGRAMMING
PRACTICAL RECORD

PAPER CODE : BS - 151

Name of the student : HARISH GHASOLIA

University Roll No. :

Branch : AI & DS

Section/ Group : O2

PRACTICAL DETAILS

a) Experiments according to the list provided by GGSIPU

Experiment Name Date of Date of Remarks Marks


performance checking (10)
Program to
1 perform calculator 13/12/21
operations(+,-
,/,*,%).

Program to
2 Calculate simple 13/12/21
interest.

Program to convert
3 Celsius to 13/12/21
Fahrenheit.

Program to
4 compute average of 13/12/21
three numbers.

Program to check a
5 given number is 13/12/21
even or odd.

Program to find
6 greater among three 20/12/21
numbers.

MAIT 2
Program to
7 compute area of 20/12/21
circle.

Program to
8 compute area of 20/12/21
rectangle.

Program to
9 compute 20/12/21
volume and
surface area of
a cube.
Program to
10 compute gross 20/12/21
salary,

C Program to
11 Calculate Area 27/12/21
of Equilateral
Triangle.

C Program to
12 reverse a given 27/12/21
number.

Calculate sum
13 of 5 subjects 27/12/21
and Find
percentage.

C program to
14 compute roots 27/12/21
Quadratic
Equation.

Swap of two
15 no’s without 27/12/21
using third
variable.

Generate the
16 Fibonacci 03/01/22
Series starting
from any
two numbers.
Print First 10
17 Natural 03/01/22
Numbers.

MAIT 3
Find Factorial
18 of Number 03/01/22
Using
Recursion.

Check Whether
19 Given Number 03/01/22
is Palindrome
or Not.

Check Whether
20 Number is 03/01/22
Prime or not.

Write a c
21 program to 10/01/22
convert the
string from
upper case to
lower case.
22 Write a c program to
convert the string 10/01/22
from lower case to
upper case.

23 Program to Convert
Binary to Decimal. 10/01/22

24 Program for
Decimal to
Hexadecimal 10/01/22
Conversion.

25 Program for
Decimal number to 10/01/22
Octal Conversion.

26 Program to Convert
Decimal number
into Binary.
17/02/22

MAIT 4
27 Program to
implement Stack
Operations Using
Array. 17/02/22

28 C Program to delete
duplicate elements
in an array.
17/02/22

29 C Program to
calculate Addition
of All Elements in
Array. 17/02/22

30 C program to find
Smallest Element
in Array in C
Programming 17/02/22

31
C Program to find
Largest Element in
Array in C 24/01/22
Programming

32
C Program to
reversing an Array
Elements in C 24/01/22
Programming

33
Merging of Two
arrays in C
Programming 24/01/22

MAIT 5
34
Write a c program
for linear search
24/01/22

35
Write a c program
for linear search 24/01/22

36
Write a C function
that computes that
total sum of a 31/01/22
elements of a 2D
array

37
Write a C function
that searches for
value key in a 2D 31/01/22
array of size 6X5.
The function should
return true if found
false otherwise

38
Write a C program to
demonstrate use of
toupper, tolower, 31/01/22
pow, sqrt, fabs, floor,
ceil functions.

39
Write down a
recursive function
fab to computes
Fibonacci of the nth 31/01/22
number. Assume
fab(1)=0 & fav(2)=1.

40
Write a C program
that prints below
pattern using
nested loop?

*
**
31/01/22
***
****
MAIT 6
And
*
***
*****
*******
41

Write a C Program
to find sum of two 07/02/22
matrices

42
Write a C Program
to find subtraction
of two matrices 07/02/22

43
Write a C Program
for multiplication of
two matrices 07/02/22

44
Write a program to
calculate sum of
first 25 odd 07/02/22
numbers

45
Write a C Program to
find transpose of a 07/02/22
matrix

46
Write a C function
that computes that
maximum of a 14/02/22
specific row R in a
2D array of size 6X5

47
Write a program to
compute sum of
those array elements 14/02/22
that are prime in an
array of 10 integers

48
Write a function to
concatenate two
MAIT 7
strings and using
that a program to 14/02/22
read three Strings
and use the function
to concatenate them
and print it.

49
Write C Program that
counts the particular
word in the given
string. For example
in the string " the
string is the set of 14/02/22
charterers" , Number
of occurance of "the"
is:2

50
Write C Program to
generate two
random numbers 14/02/22
between 1 to 100.

51 Write a menu driven


program for addition,
subtraction, product
and division.

52 Write a program to
calculate sum of first
25 even numbers.

53 Write C Program to
print prime factors of
a input number >=4.

54 Write C Program to
for bubble Sort.

55 Write a c program to
develop a game
“Lucky Seven”. (sum
of rolling two dices is
compared against user
choice of 7, below 7 or
above 7 and if it
matches user choice
user wins else user
looses).
56 Write a program to
List all the arithmetic
MAIT 8
and relational
operators along with
there example
expression with
output.

57 Write a program to
calculate sum of
first 25 prime
numbers.

58 Write a program to
calculate factorial
using function.

59 Write C Program to
for selection Sort.

60 Write a program to
input a string and
print count of
different vowels in
it.

LAB-1

//1.TO COMPUTE SUM OF TWO NUMBERS


#include <stdio.h>
int main()
{ int a,b,sum,subtraction,multiplication,devide;
printf("\nEnter the first number:");
scanf("%d",&a);
printf("\nEnter the second number:");
scanf("%d",&b);
sum=a+b;
printf("Sum=%d\n",sum);
subtraction=a-b;

MAIT 9
printf("subtraction=%d\n",subtraction);
multiplication=a*b;
printf("multiplication=%d\n",multiplication);
devide=a/b;
printf("devidation=%d\n",devide);
return 0;

Output-

MAIT 10
//2.TO CALCULATE SIMPLE INTEREST
#include <stdio.h>
int main()
{ int p,t,rate,amt,si;
MAIT 11
printf("\nEnter principal amount:");
scanf("%d",&p);
printf("\nEnter rate of yearly interest:");
scanf("%d",&rate);
printf("\nEnter time of interest:");
scanf("%d",&t);
si=(p*t*rate)/100;
amt=p+si;
printf("\nSimple interest=%d",si);
printf("\nTotal amount=%d",amt);

Output-

MAIT 12
//3.TO CONVERT CELSIUS TO FAHRENHEIT

MAIT 13
#include <stdio.h>
int main()
{ int c,f;
printf("\nEnter the temperature in celsius:");
scanf("%d",&c);
f=(c*9/5)+32;
printf("\nThe temperature in fahrenheit=%d",f);

MAIT 14
Output-

MAIT 15
//4.TO COMPUTE AVERAGE OF THREE NUMBERS
#include <stdio.h>
int main()
{ int a,b,c,avg;
printf("\nEnter the first number:");
scanf("%d",&a);
printf("\nEnter the second number:");
scanf("%d",&b);
printf("\nEnter the third number:");
scanf("%d",&c);
avg=(a+b+c)/3;
printf("\nAverage=%d",avg);

MAIT 16
Output-

MAIT 17
//5.TO CHECK IF A NUMBER IS ODD OR EVEN
#include <stdio.h>
int main()

{ int a;
printf("\nEnter the number to be checked:");
scanf("%d",&a);
if(a%2==1)
printf("\nThe number is odd");
else
printf("\nThe number is even");

MAIT 18
Output-

MAIT 19
//6.TO FIND THE GREATEST NUMBER AMONG THREE NUMBERS
#include <stdio.h>
int main()
{ int a,b,c,t;
printf("\nEnter the first number:");
scanf("%d",&a);
printf("\nEnter the second number:");
scanf("%d",&b);
printf("\nEnter the third number:");
scanf("%d",&c);

if(a>b)
{ if(a>c)
t=a;
else
t=c;
}
else
{ if(b>c)
t=b;
else
t=c;
}
printf("\nGreatest number=%d",t);

MAIT 20
Output-

MAIT 21
//7.TO COMPUTE THE AREA OF A CIRCLE
#include <stdio.h>
#include <math.h>

int main()
{ float r,area;
printf("\nEnter the radius of the circle:");
scanf("%f",&r);
area=3.14*pow(r,2);
printf("\nArea of the circle=%f",area);

MAIT 22
Output-

MAIT 23
-//8.TO COMPUTE THE AREA OF A RECTANGLE
#include <stdio.h>

int main()
{ float l,b,area;
printf("\nEnter the length of the rectangle:");
scanf("%f",&l);
printf("\nEnter the breadth of the rectangle:");
scanf("%f",&b);
area=l*b;
printf("\nArea of the rectangle=%f",area);

MAIT 24
Output-

MAIT 25
//9.TO COMPUTE VOLUME AND SURFACE AREA OF CUBE
#include <stdio.h>
#include <math.h>

int main()
{ float a,volume,area;
printf("\nEnter the length of the side of the cube:");
scanf("%f",&a);
area=6*pow(a,2);
volume=pow(a,3);
printf("\nSurface area of the cube=%f",area);
printf("\nVolume of the cube=%f",volume);

MAIT 26
Output-

MAIT 27
//10.Program to convert Celsius to Fahrenheit
#include <stdio.h>

int main()
{ int bs,hra,ta,sum;
printf("\nEnter the basic salary:");
scanf("%d",&bs);
hra=(3*bs)/10;
ta=bs/10;
sum=bs+hra+ta;
printf("\nGross salary=%d",sum);

MAIT 28
Output-

MAIT 29
LAB-2
//11.TO COMPUTE AREA OF AN EQUILATERAL TRIANGLE
#include <stdio.h>
#include <math.h>

int main()
{ float s,area;
printf("\nEnter the side of the triangle:");
scanf("%f",&s);
area=(sqrt(3)/4)*pow(s,2);
printf("\nArea of the triangle=%f",area);

MAIT 30
Output-

MAIT 31
//12.TO REVERSE A GIVEN NUMBER
#include <stdio.h>
#include <math.h>

int main()
{ int a,b,i=0,sum=0;
printf("\nEnter the number to be reversed:");
scanf("%d",&a);
b=a;
while (b!=0)
{i++;
b=b/10;
};
b=a;
for(int x=1 ;i!=0; x++)
{i--;
int d;
d=b%10;
b=b/10;
sum=sum+(d*pow(10,i));
};
printf("\n%d",sum);

MAIT 32
Output-

MAIT 33
//13 TO COMPUTE SUM AND PERCENTAGE OF FIVE SUBJECTS
#include <stdio.h>
int main()
{ float m1,m2,m3,m4,m5,sum=0,perc;
printf("\nEnter the marks obtained in first subject:");
scanf("%f",&m1);
printf("\nEnter the marks obtained in second subject:");
scanf("%f",&m2);
printf("\nEnter the marks obtained in third subject:");
scanf("%f",&m3);
printf("\nEnter the marks obtained in fourth subject:");
scanf("%f",&m4);
printf("\nEnter the marks obtained in fifth subject:");
scanf("%f",&m5);
sum=m1+m2+m3+m4+m5;
perc=sum/5;
printf("\nTotal marks=%f",sum);
printf("\nPercantage=%f%%",perc);

MAIT 34
Output-

MAIT 35
//14 TO COMPUTE ROOTS OF A QUADRATIC EQUATION
#include <stdio.h>
#include <math.h>

int main()
{ float a, b, c, d, root1, root2;
printf("\nEnter coefficients a, b and c: ");
scanf("%f %f %f", &a, &b, &c);

d=(b*b)-(4*a*c);

if (d >= 0)
{ root1 = (-b + sqrt(d)) / (2 * a);
root2 = (-b - sqrt(d)) / (2 * a);
printf("root 1=%f and root 2=%f", root1, root2);
}

else
{
printf("\nThe roots are not real");
}
}

MAIT 36
Output-

MAIT 37
//15 TO SWAP TWO NUMBERS WITHOUT A THIRD VARIABLE
#include <stdio.h>
int main ()
{ int a, b;
printf ("\nEnter the first number:");
scanf ("%d", &a);
printf("\nEnter the second number:");
scanf("%d",&b);
a=a+b;
b=a-b;
a=a-b;
printf("\nNew first number=%d",a);
printf("\nNew second number=%d",b);

MAIT 38
Output-

MAIT 39
//16 TO PRINT FIBONACCI SEQUENCE FROM TWO NUMBERS
#include <stdio.h>
int main ()
{ int a, b,sum=0;
printf ("\nEnter the first number:");
scanf ("%d", &a);
printf("\nEnter the second number:");
scanf("%d",&b);
printf("%d,%d",a,b);

while (sum<10000)
{ sum=a+b;
a=b;
b=sum;
printf(",%d",sum);
}
}

MAIT 40
Output-

MAIT 41
//17 TO PRINT THE FIRST TEN NATURAL NUMBERS
#include <stdio.h>

int main ()
{ int i=0;
while (i<10)
{ i++;

printf("%d,",i);
};
}

Output-

MAIT 42
//18 TO PRINT THE FACTORIAL OF A NUMBER
#include <stdio.h>
int main ()
{ int i,fact=1;
printf("\nEnter a number:");
scanf("%d",&i);
while (i!=1)
{ fact=fact*i;
i--;
};
printf("%d",fact);
}

MAIT 43
Output-

MAIT 44
//19 TO CHECK IF A NUMBER IS A PALINDROME
#include <stdio.h>
#include <math.h>

int main()
{ int a,b,i=0,sum=0;
printf("\nEnter the number to be checked:");
scanf("%d",&a);
b=a;
while (b!=0)
{i++;
b=b/10;
};
b=a;
for(int x=1 ;i!=0; x++)
{i--;
int d;
d=b%10;
b=b/10;
sum=sum+(d*pow(10,i));
};
if(sum==a)
printf("\nThe number is a palindrome");
else
printf("\nThe number is not a palindrome");

MAIT 45
}

Output-

MAIT 46
//20 TO CHECK IF A NUMBER IS PRIME
#include <stdio.h>
int main()
{ int a,i,x=0;
printf("\nEnter the number to be checked:");
scanf("%d",&a);
i=a-1;
for( ;i!=1;i--)
{if(a%i==0)
{x++;
break;
};

if(x==0)
printf("\n%d is a prime number",a);
else
printf("\n%d is not a prime number",a);
}

MAIT 47
Output-

MAIT 48
LAB-3
//21 TO CHANGE LOWERCASE STRING TO UPPERCASE
#include<stdio.h>
#include<string.h>
int main()
{ char str[25];
int i=0;
printf("\nEnter the string:");
scanf("%s",str);
for(i=0;i<=strlen(str);i++)
{
if(str[i]>=65 && str[i]<=100)
str[i]=str[i]+32;
}
printf("\nThe new string is: %s",str);

MAIT 49
Output-

MAIT 50
//22 TO CHANGE UPPERCASE STRING TO LOWERCASE
#include<stdio.h>
#include<string.h>
int main()
{ char str[25];
int i=0;
printf("\nEnter the string:");
scanf("%s",str);
for(i=0;i<=strlen(str);i++)
{
if(str[i]>=97 && str[i]<=122)
str[i]=str[i]-32;
}
printf("\nThe new string is: %s",str);

MAIT 51
Output-

MAIT 52
//23 TO CONVERT NUMBER TO DECIMAL
#include<stdio.h>
#include<math.h>

int main()
{ int i=0,bin,a,deci=0;
printf("\nEnter the binary number:");
scanf("%d",&bin);
a=bin;
while(a!=0)
{ i++;
a=a/10;
};
a=bin;

for(int x=0 ;i!=0 ; x++ )


{ i--;
deci=deci+((a%10)*pow(2,x));
a=a/10;
};
printf("\nThe number is decimal is: %d",deci);

MAIT 53
Output-

MAIT 54
//24 TO CONVERT DECIMAL TO HEXADECIMAL
#include <stdio.h>
int main ()
{ int d,i=0,a;
char hex[20],b;
printf ("\nEnter the decimal number:");
scanf ("%d", &d);
a=d;
while(a!=0)
{ b=a%16;
a=a/16;
if (b < 10)
hex[i] = 48 + b;
else
hex[i] = 55 + b;
i++;
}
for( ;i>=0 ;i-- )
{printf("%c",hex[i]);};
}

MAIT 55
Output-

MAIT 56
//25 TO CONVERT DECIMAL NUMBER TO OCTAL
#include <stdio.h>
#include <math.h>
int main()
{ int i=0,deci,a,oct=0;
printf("\nEnter the decimal number:");
scanf("%d",&deci);
a=deci;
while(a!=0)
{ i++;
a=a/8;
};
a=deci;

for(int x=0 ;i!=0 ; x++ )


{ i--;
oct=oct+((a%8)*pow(10,x));
a=a/8;
};
printf("\nThe number is decimal is: %d",oct);
}

MAIT 57
Output-

MAIT 58
//26 TO CONVERT DECIMAL NUMBER TO BINARY

#include <stdio.h>
int main()
{ int i=0,deci,a;
char bin[20];
printf("\nEnter the decimal number:");
scanf("%d",&deci);
while(deci!=0)
{ a=deci%2;
deci=deci/2;
bin[i]=48+a;
i++;
}
printf("\n");

for(i--;i>=0 ;i-- )
printf("%c",bin[i]);
}

MAIT 59
Output-

MAIT 60
//27 TO IMPLEMENT STACK OPERATIONS USING ARRAYS
#include<stdio.h>

int stack[10],choice,n,top,x,i;

int push();
int pop();
int display();

int main()
{
top = -1;
printf("\n Enter the size of STACK : ");
scanf("%d",&n);
printf("\nSTACK IMPLEMENTATION USING ARRAYS\n");
do
{
printf("\n1.PUSH\n2.POP\n3.DISPLAY\n4.EXIT\n");
printf("\nEnter the choice : ");
scanf("%d",&choice);
switch(choice)
{
case 1:
{
push();

MAIT 61
break;
}
case 2:
{
pop();
break;
}
case 3:
{
display();
break;
}
case 4:
{
break;
}
default:
{
printf ("\nInvalid Choice\n");
}}}
while(choice!=4);
}

int push()
{
if(top >= n - 1)
{
printf("\nSTACK OVERFLOW\n");

}
else
{
printf("Enter a value to be pushed : ");
scanf("%d",&x);
top++;
stack[top] = x;
}}

int pop()
{
if(top <= -1)
{
printf("\nSTACK UNDERFLOW\n");
}
else
{
printf("\nThe popped element is %d",stack[top]);
top--;
}}

int display()
{

MAIT 62
if(top >= 0)
{
printf("\nELEMENTS IN THE STACK\n\n");
for(i = top ; i >= 0 ; i--)
printf("%d\t",stack[i]);
}
else
{
printf("\nEMPTY STACK\n");
}
}

Output-

MAIT 63
//28 To delete dublicate elements in an array
#include<stdio.h>
#include<stdlib.h>
int main(){
int a[50],i,j,k, count = 0, dup[50], number;
printf("Enter size of the array\n");
scanf("%d",&number);
MAIT 64
printf("Enter Elements of the array:\n");
for(i=0;i<number;i++){
scanf("%d",&a[i]);
dup[i] = -1;
}
printf("Entered element are: \n");
for(i=0;i<number;i++){
printf("%d ",a[i]);
}
for(i=0;i<number;i++){
for(j = i+1; j < number; j++){
if(a[i] == a[j]){
for(k = j; k <number; k++){
a[k] = a[k+1];
}
j--;
number--;
}
}
}
printf("\nAfter deleting the duplicate element the Array is:\n");
for(i=0;i<number;i++){
printf("%d ",a[i]);
}
}

Output-

MAIT 65
MAIT 66
//29 TO CALCULATE SUM OF ELEMENTS OF AN ARRAY

#include <stdio.h>

int main()
{
int arr[10],i=0,size, sum=0;
printf("\nEnter size of the array:");
scanf("%d",&size);
printf("\nEnter the elements of the array:\n");
for( ;i<size;i++)
scanf("%d",&arr[i]);

i=0;
for( ;i<size ;i++ )
sum=sum+arr[i];
printf("\nSum=%d",sum);
}

Output-

MAIT 67
MAIT 68
//30 TO FIND SMALLEST ELEMENT OF AN ARRAY
#include <stdio.h>

int main()
{
int arr[10],i=0,size,x,y;
printf("\nEnter size of the array:");
scanf("%d",&size);
printf("\nEnter the elements of the array:\n");
for( ;i<size;i++)
scanf("%d",&arr[i]);

i=0;
x=arr[i];
for(i++ ;i<size ;i++ )
{
y=arr[i];
if(x>=y)
x=y;

}
printf("\nSmallest element=%d",x);
return 0;
}

MAIT 69
Output-

MAIT 70
LAB-4

//31.TO FIND LARGEST ELEMENT OF AN ARRAY


#include <stdio.h>

int main()
{
int arr[10],i=0,size,x,y;
printf("\nEnter size of the array:");
scanf("%d",&size);
printf("\nEnter the elements of the array:\n");
for( ;i<size;i++)
scanf("%d",&arr[i]);

i=0;
x=arr[i];
for(i++ ;i<size ;i++ )
{
y=arr[i];
if(x<=y)
x=y;

}
printf("\nLargest element=%d",x);
return 0;
}

MAIT 71
Output-

MAIT 72
//32.TO REVERSE THE ELEMENTS OF AN ARRAY
#include <stdio.h>

int main()
{
int arr[10],i=0,j=0,size,x;
printf("\nEnter size of the array:");
scanf("%d",&size);
printf("\nEnter the elements of the array:\n");
for( ;i<size;i++)
scanf("%d",&arr[i]);

i=0;
j=size-1;
for( ;i<j ; i++,j-- )
{
x=arr[i];
arr[i]=arr[j];
arr[j]=x;
};
i=0;
printf("\nThe new array is:\n");
for( ;i<size ;i++ )
printf("\t%d",arr[i]);
return 0;

MAIT 73
Output-

MAIT 74
//33.TO MERGE ELEMENTS OF TWO ARRAYS
#include <stdio.h>

int main()
{
int arr1[10],arr2[10],i,size1,size2;
int arr3[20],size3;
printf("\nEnter size of the first array:");
scanf("%d",&size1);
printf("\nEnter the elements of the array:\n");
for( i=0;i<size1;i++)
scanf("%d",&arr1[i]);

printf("\nEnter size of the second array:");


scanf("%d",&size2);
printf("\nEnter the elements of the array:\n");
for(i=0 ;i<size2;i++)
scanf("%d",&arr2[i]);

size3=size1+size2;

for(i=0 ;i<size1 ; i++ )


arr3[i]=arr1[i];

for( int j=0;i<size3 ;i++,j++ )


arr3[i]=arr2[j];

printf("\nThe new array is:\n");


for(i=0 ;i<size3 ;i++ )
printf("\t%d",arr3[i]);
return 0;
}

MAIT 75
Output-

MAIT 76
//34. TO WRITE A PROGRAM FOR LINEAR SEARCH
#include <stdio.h>
#include <string.h>

int search(int arr[], int n, int x)


{ int i;
for (i = 0; i < n; i++)
if (arr[i] == x)
return i;
return -1;
}

int main()
{ int arr[] = { 1,2,3,4,5,6,7,8 };
int x;
printf("\nEnter the number to be searched:");
scanf("%d",&x);
int n = sizeof(arr);
int result = search(arr, n, x);
if(result == -1)
printf("Element is not present in array");
else
printf("Element is present at index %d", result);
}

MAIT 77
Output-

MAIT 78
//35. Write a c program for binary search.

#include<stdio.h>

int binarySearch(int arr[], int n, int key)


{
int start=0, end=n, mid;
while(start<=end)
{
mid=(start+end)/2;

if(arr[mid]<key)
start=mid+1;
else if(arr[mid]>key)
end=mid-1;
else
return mid;
}

return -1;
}

int main()
{
int n, key, i, temp;
printf("\nEnter the size of array: ");
scanf("%d",&n);

int arr[n];
printf("\nEnter elements of array: ");
for(i=0; i<n; i++)
scanf("%d",&arr[i]);

printf("\nEnter the element to search: ");


scanf("%d",&key);

//sorting
for(i=0; i<n-1; i++)
MAIT 79
if(arr[i]>arr[i+1])
{
temp=arr[i];
arr[i]=arr[i+1];
arr[i+1]=temp;
}
printf("\nThe sorted Array is: ");
for(i=0;i<n;i++)
printf("%d ",arr[i]);

int pos=binarySearch(arr,n,key);
if(pos<0)
printf("\n\nElement '%d' is not present in array!",key);
else
printf("\n\nYour element is present at index %d",pos);

return 0;
}

MAIT 80
Output-

MAIT 81
//36.TO CALCULATE SUM OF ELEMENTS OF A 2D ARRAY
#include <stdio.h>
int sume(int arr[100][100],int r,int c)
{
int sum=0;
for( int i=0;i<r ;i++ )
for(int j=0 ; j<c; j++)
sum=sum+arr[i][j];
printf("\nSum of elements=%d",sum);

int main()
{
int arr[100][100],sum=0,r,c;
printf("\nEnter the number of rows:");
scanf("%d",&r);
printf("\nEnter the number of columns:");
scanf("%d",&c);
printf("\nEnter the elements of the array:");
for( int i=0;i<r ;i++ )
for( int j=0;j<c ;j++ )
scanf("%d",&arr[i][j]);

sume(arr,r,c);

MAIT 82
Output-

MAIT 83
//37.TO FIND A NUMBER IN A 2D ARRAY
#include <stdio.h>

int sume(int arr[6][5],int x)


{
int y=0;
for( int i=0;i<6 ;i++ )
for(int j=0 ; j<5; j++)
if(x==arr[i][j])
{
printf("\nThe number is present at [%d][%d] position",i,j);
y++;
}
if(y==0)
printf("\nThe number is not present in the array");

int main()
{
int arr[6][5],t=0,x;
for( int i=0;i<6 ;i++ )
for( int j=0;j<5 ;j++ )
{
arr[i][j]=t;
t++;
}

printf("\nEnter number to be searched:");


scanf("%d",&x);
sume(arr,x);

MAIT 84
Output-

MAIT 85
//38.TO DEMONSTRATE USE OF TOUPPER, TOLOWER, POW, SQRT, FABS, FLOOR &
CEIL FUNCTIONS
#include <stdio.h>
#include <ctype.h>
#include <math.h>

void changeup()
{
char str1[25];
int i=0;
printf("\nEnter a string to be changed:");
scanf("%s",&str1);
printf("\nNew string=");
for( ;str1[i]!='\0' ;i++ )
{
printf("%c",toupper(str1[i]));
}
}

void changelow()
{
char str[25];
int i=0;
printf("\nEnter a string to be changed:");
scanf("%s",&str);
printf("\nNew string=");
for( ;str[i]!='\0' ;i++ )
{
printf("%c",tolower(str[i]));
}
}

void power()
MAIT 86
{
int num,pw,ans;
printf("\nEnter the number and its power:");
scanf("%d",&num);
scanf("%d",&pw);
ans=pow(num,pw);
printf("Answer=%d",ans);
}

void sqroot()
{
float num;
printf("\nEnter a number:");
scanf("%f",&num);
printf("Answer=%f",sqrt(num));
}

void fabbbs()
{
double num;
printf("\nEnter a number:");
scanf("%lf",&num);
printf("Answer=%lf",fabs(num));
}

void apprxd()
{
float num;
printf("\nEnter a number:");
scanf("%f",&num);
printf("Answer=%f",floor(num));
}

void apprxu()
{
float num;
printf("\nEnter a number:");
scanf("%f",&num);
printf("Answer=%f",ceil(num));
}

MAIT 87
void main()
{
int r=0;
printf("\t\t\tC FUNCTIONS\n1.Change string to uppercase\n2.Change string to
lowercase");
printf("\n3.Calculate exponent of a number\n4.Calculate squareroot of a
number");
printf("\n5.Calculate modulus of a number\n6.Approximate to nearest lower
integer");
printf("\n7.Approximate to nearest greater integer\n8.Exit");

while(r!=8)
{
printf("\nEnter your choice:");
scanf("%d",&r);
switch(r)
{
case 1: changeup(); break;
case 2: changelow(); break;
case 3: power(); break;
case 4: sqroot(); break;
case 5: fabbbs(); break;
case 6: apprxd(); break;
case 7: apprxu(); break;
case 8: break;
default: printf("\nInvalid input");
};
};
}

MAIT 88
Output-

MAIT 89
//39.TO COMPUTE FIBONACCI OF A NUMBER
#include <stdio.h>

int n;
long long x = 0, y = 1;
long long fibo(int n) {
if (n == 1)
return x;
else if (n == 2)
return 1;
else if (n == 3)
return y + x;
y += x;
x = y - x;
return fibo(n - 1);
}

int main() {
printf("\nEnter the number:");
scanf("%d", &n);
printf("%lld", fibo(n));
return 0;
}

MAIT 90
Output-

MAIT 91
//40.*TO PRINT THE FOLLOWING PATTERN
*
**
***
****
***** */

#include <stdio.h>

int main()
{
int i=5,x=0;
for( ;i>=0 ;i--,x++ )
{
for(int t=i;t>=0;t-- )
printf(" ");
for(int m=5-x;m<=5;m++)
printf("*");
printf("\n");
}
}

MAIT 92
Output-

MAIT 93
LAB-5

//41.TO FIND SUM OF TWO MATRICES


#include <stdio.h>

int main()
{
int r,c,arr1[100][100],arr2[100][100],arr3[100][100];
printf("\nEnter the number of columns:");
scanf("%d",&c);
printf("\nEnter the number of rows:");
scanf("%d",&r);

printf("\nEnter elements of first matrix:");


for(int i=0 ;i<r ;++i )
for(int j=0 ;j<c ;++j )
scanf("%d",&arr1[i][j]);

printf("\nEnter elements of second matrix:");


for(int i=0;i<r;++i)
for(int j=0 ;j<c ;++j )
scanf("%d",&arr2[i][j]);

for(int i=0 ;i<r ;++i )


for(int j=0 ;j<c ;++j )
{arr3[i][j]=arr1[i][j]+arr2[i][j];};

printf("The new matrix is:\n");


for(int i=0 ;i<r ;++i )
{
for(int j=0 ;j<c ;++j )
printf("%d\t",arr3[i][j]);
printf("\n");
};
}
Output:

MAIT 94
MAIT 95
//42.TO FIND DIFFERENCE OF TWO MATRICES
#include <stdio.h>

int main()
{
int r,c,arr1[100][100],arr2[100][100],arr3[100][100];
printf("\nEnter the number of columns:");
scanf("%d",&c);
printf("\nEnter the number of rows:");
scanf("%d",&r);

printf("\nEnter elements of first matrix:");


for(int i=0 ;i<r ;++i )
for(int j=0 ;j<c ;++j )
scanf("%d",&arr1[i][j]);

printf("\nEnter elements of second matrix:");


for(int i=0;i<r;++i)
for(int j=0 ;j<c ;++j )
scanf("%d",&arr2[i][j]);

for(int i=0 ;i<r ;++i )


for(int j=0 ;j<c ;++j )
{arr3[i][j]=arr1[i][j]-arr2[i][j];};

printf("The new matrix is:\n");


for(int i=0 ;i<r ;++i )
{
for(int j=0 ;j<c ;++j )
printf("%d\t",arr3[i][j]);
printf("\n");
};

Output:
MAIT 96
MAIT 97
//43.TO FIND PRODUCT OF TWO MATRICES
#include<stdio.h>
int main()
{
int a[10][10],b[10][10],mul[10][10],r,c,i,j,k;
printf("\nEnter the number of row=");
scanf("%d",&r);
printf("\nEnter the number of column=");
scanf("%d",&c);
printf("\nEnter the first matrix element=\n");
for(i=0;i<r;i++)
{
for(j=0;j<c;j++)
{
scanf("%d",&a[i][j]);
}
}
printf("\nEnter the second matrix element=\n");
for(i=0;i<r;i++)
{
for(j=0;j<c;j++)
{
scanf("%d",&b[i][j]);
}
}

printf("\nMultiplication of the matrix=\n");


for(i=0;i<r;i++)
{
for(j=0;j<c;j++)
{
mul[i][j]=0;
for(k=0;k<c;k++)
{
mul[i][j]+=a[i][k]*b[k][j];
}
MAIT 98
}
}

for(i=0;i<r;i++)
{
for(j=0;j<c;j++)
{
printf("%d\t",mul[i][j]);
}
printf("\n");
}
return 0;
}

MAIT 99
Output:

MAIT 100
//44.TO CALCULATE SUM OF FIRST 25 ODD NUMBERS
#include <stdio.h>
#include <conio.h>

int main()
{ int a=1,sum=0,i=25;

while(i!=0)
{
i--;
sum=sum+a;
a=a+2;
};
printf("Sum=%d",sum);

MAIT 101
Output:

MAIT 102
//45.O FIND TRANSPOSE OF A MATRIX
#include<stdio.h>
#include <stdio.h>

int main()
{
int r,c,arr1[100][100];
printf("\nEnter the number of columns:");
scanf("%d",&c);
printf("\nEnter the number of rows:");
scanf("%d",&r);

printf("\nEnter elements of first matrix:");


for(int i=0 ;i<r ;++i )
for(int j=0 ;j<c ;++j )
scanf("%d",&arr1[i][j]);

printf("\nGIVEN MATRIX=\n");
for(int i=0 ;i<r ;++i )
{ for(int j=0 ;j<c ;++j )
printf("%d\t",arr1[i][j]);
printf("\n");
};

printf("\nTRANSPOSE=\n");
for(int i=0 ;i<r ;++i )
{
for(int j=0 ;j<c ;++j )
printf("%d\t",arr1[j][i]);
printf("\n");
};
}

MAIT 103
Output:

MAIT 104
//46.TO FIND MAX NUMBER IN A GIVEN ROW IN A 2D ARRAY
#include <stdio.h>

void display(int arr[100][100],int row,int c)


{
int i=0,x;
x=arr[i][row];
for(i++;i<c ;++i )
{
if(x<=arr[i][row])
x=arr[i][row];

};
printf("\nMax=%d",x);
}

int main()
{
int r,c,arr1[100][100],row;
printf("Enter the number of columns:");
scanf("%d",&c);
printf("Enter the number of rows:");
scanf("%d",&r);

printf("Enter elements of first matrix:");


for(int i=0 ;i<r ;++i )
for(int j=0 ;j<c ;++j )
scanf("%d",&arr1[i][j]);

printf("\n2D ARRAY=\n");
for(int i=0 ;i<c ;++i )
{
for(int j=0 ;j<r ;++j )
printf("%d\t",arr1[i][j]);
printf("\n");
};
printf("\nEnter the row to be searched:");
scanf("%d",&row);
MAIT 105
display(arr1,row,c);

MAIT 106
MAIT 107
//47.TO FIND THE SUM OF PRIME ELEMENTS OF AN ARRAY
#include <stdio.h>

int prime(int a)
{
int i,x=0;
i=a-1;
for( ;i!=1;i--)
{if(a%i==0)
{x++;
break;
};

if(x==0)
return 1;
else
return 0;

int main()
{
int arr[100],i=0,size,sum=0;
printf("\nEnter size of the array:");
scanf("%d",&size);
printf("\nEnter the elements of the array:\n");
for( ;i<size;i++)
scanf("%d",&arr[i]);

for(i=0 ;i<size ;i++ )


{
if (prime(arr[i])==1)
sum+=arr[i];
};
printf("\nSum=%d",sum);
}
MAIT 108
Output:

MAIT 109
MAIT 110
//48.TO CONCATENATE TWO STRINGS INTO ONE STRING,THEN ADD A THIRD
STRING
#include <stdio.h>
#include <string.h>

void merge(char str[200])


{
int i=0,x,y,j;
char str1[25];
printf("Enter the word to enter:");
scanf("%s",str1);
x=strlen(str);
y=strlen(str1);
for( ;i<y ;i++ )
str[x+i]=str1[i];
str[x+i]='\0';
}

void display(char str[200])


{
int i=0,x;
x=strlen(str);
printf("STRING=\n");
for( ;i<x ;i++ )
{
printf("%c",str[i]);
}

int main()
{
char string[200],str1[25];
int opt=0;
printf("Enter a word:");
scanf("%s",string);
printf("\n\t\t\tSTRING OPERATIONS\n1.Add another word\t2.Print string\
t3.Exit");

while(opt!=3)
MAIT 111
{
printf("\nEnter your choice:");
scanf("%d",&opt);
switch(opt)
{
case 1: merge(string);
break;
case 2: display(string);
break;
case 3: break;
default: printf("INVALID INPUT");
}

Output:

MAIT 112
MAIT 113
//49.TO COUNT THE NUMBER OF A PARTICULAR WORD IN A SENTENCE

#include<stdio.h>
#include<string.h>
int main()
{
char str[100], word[20];
int i, j, ls, lw, temp, countW=0, chk;
printf("Enter the String: ");
gets(str);
printf("Enter a Word: ");
gets(word);
ls = strlen(str);
lw = strlen(word);
for(i=0; i<ls; i++)
{
temp = i;
for(j=0; j<lw; j++)
if(str[i]==word[j])
i++;
chk = i-temp;
if(chk==lw)
countW++;
i = temp;
}
printf("\nOccurrence = %d", countW);}

MAIT 114
Output:

MAIT 115
//50.TO GENERATE RANDOM NUMBERS BETWEEN 1 AND 100
#include <stdio.h>
#include <stdlib.h>
#include <time.h>

int main()
{
srand(time(0));
int num;
num=(rand()%100);
printf("Random Number=%d", num);
}

MAIT 116
Output:

MAIT 117
LAB-6
//51. MENU DRIVEN PROGRAM FOR ADDITION, SUBTRACTION,MULT & DIVISION
#include<stdio.h>
void add()
int a,b;
printf("\nEnter two numbers to add:");
scanf("%d%d",&a,&b);
printf("%d+%d=%d",a,b,a+b);
}

void subt()
{
int a,b;
printf("Enter two numbers to subtract:");
scanf("%d%d",&a,&b);
printf("%d-%d=%d",a,b,a-b);
}
void mult()
{
int a,b;
printf("Enter two numbers to multiply:");
scanf("%d%d",&a,&b);
printf("%d*%d=%d",a,b,a*b);
}
void divi()
{
float a,b;
printf("Enter the dividend:");
scanf("%f",&a);
printf("Enter the divisor:");
scanf("%f",&b);
printf("%f/%f=%f",a,b,a/b);
}
void main()
{
int ch=0;
printf("\t\t\t\t\tARITHMETIC FUNCTIONS\n");
printf("1.Addition(+)\n2.Subtraction(-)\n3.Multiplication(*)\n4.Division(\\)\n5.EXIT");
while(ch!=5)
{
printf("\nEnter your choice:");
scanf("%d",&ch);
switch(ch)
{
case 1 : add();break;
case 2 : subt();break;
case 3 : mult();break;
MAIT 118
case 4 : divi();break;
case 5 : break;
default: printf("INVALID INPUT");

};
};
return 0;
}

Output:

MAIT 119
//52. TO CALCULATE SUM OF FIRST 25 EVEN NUMBERS
#include <stdio.h>
#include <conio.h>

int main()
{ int a=0,sum=0,i=25;

while(i>=0)
{
i--;
sum=sum+a;
a=a+2;
};
printf("Sum=%d",sum);
return 0;

Output:

MAIT 120
//53.TO PRINT PRIME FACTORS OF A GIVEN NUMBER
#include<stdio.h>
int checkprime(int a)
{ int i,x=0;
i=a-1;
for( ;i!=1;i--)
{if(a%i==0)
{x++;
break;
};
}
return x;
}
void main()
{
int n,i=2;
printf("Enter a number:");
scanf("%d",&n);
if(n<=4)
printf("INVALID INPUT");
else
{
printf("Prime Factors=");
for( ;i<=n ;i++ )
{
if (checkprime(i)==0)
if (n%i==0)
printf("%d",i);
}
}
return 0;
}
MAIT 121
Output:

MAIT 122
//54.TO WRITE A PROGRAM FOR BUBBLE SORT

#include <stdio.h>

void bubbleSort(int arr[], int n)


{
int i, j,temp;
for (i = 0; i < n; i++)
for (j = 0; j < n; j++)
if (arr[j] > arr[i])
{ temp=arr[j];
arr[j]=arr[i];
arr[i]=temp;
}
}

void main()
{
int arr[10],i=0,size,n,y;
printf("\nEnter size of the array:");
scanf("%d",&size);
printf("\nEnter the elements of the array:\n");
for( ;i<size;i++)
scanf("%d",&arr[i]);
bubbleSort(arr,size);
for(i=0 ;i<size ;i++ )
printf("\t%d",arr[i]);
return 0;}

Output:

MAIT 123
MAIT 124
//55.LUCKY SEVEN GAME
#include <stdio.h>
#include <time.h>
#include <stdlib.h>

void main()
{
int ch=0,dice;
srand(time(0));
while(ch!=4)
{
printf("\n\t\t\tLUCKY SEVEN\n1.Bet on 7\n2.Bet on below 7\n3.Bet on above 7\n4.EXIT");
printf("\nEnter your choice:");
scanf("%d",&ch);
switch(ch)
{
case 1 : { printf("DICE ROLLED");
dice=(rand()%10)+2;
printf("\n\t\t%d",dice);
if(dice==7)
printf("\nYOU WIN");
else
printf("\nYOU LOSE");
break; }
case 2 : { printf("DICE ROLLED");
dice=(rand()%10)+2;
printf("\n\t\t%d",dice);
if(dice<7)
printf("\nYOU WIN");
else
printf("\nYOU LOSE");
break; }
case 3 : { printf("DICE ROLLED");
dice=(rand()%10)+2;
printf("\n\t\t%d",dice);
if(dice>7)
printf("\nYOU WIN");
else
printf("\nYOU LOSE");
break; }
case 4 : break;
default: printf("INVALID INPUT");
}
}
return 0;

MAIT 125
}

Output:

MAIT 126
//56.TO DEMONSTRATE USE OF ARITHMETIC AND RELATIONAL OPERATORS

#include <stdio.h>
void add()
{
int a,b;
printf("\nEnter two numbers to add:");
scanf("%d%d",&a,&b);
printf("%d+%d=%d",a,b,a+b);
}

void subt()
{
int a,b;
printf("Enter two numbers to subtract:");
scanf("%d%d",&a,&b);
printf("%d-%d=%d",a,b,a-b);
}

void mult()
{
int a,b;
printf("Enter two numbers to multiply:");
scanf("%d%d",&a,&b);
printf("%d*%d=%d",a,b,a*b);
}

void divi()
{
float a,b;
printf("Enter the dividend:");
scanf("%f",&a);
printf("Enter the divisor:");
scanf("%f",&b);
printf("%f/%f=%f",a,b,a/b);
}

void modu()
{
int a,b;
printf("Enter the dividend:");
scanf("%d",&a);

MAIT 127
printf("Enter the divisor:");
scanf("%d",&b);
printf("(%d)%(%d)=%d",a,b,a%b);

void equal()
{
int a,b;
printf("Enter two numbers to check equal:");
scanf("%d%d",&a,&b);
if(a==b)
printf("a==b = 1\tTherefore they are equal");
else
printf("a==b = 0\tTherefore they are not equal");
}
void nequal()
{
int a,b;
printf("Enter two numbers to check not equal:");
scanf("%d%d",&a,&b);
if(a!=b)
printf("a!=b = 1\tTherefore they are not equal");
else
printf("a!=b = 0\tTherefore they are equal");
}

void great()
{
int a,b;
printf("Enter two numbers to compare:");
scanf("%d%d",&a,&b);
if(a>b)
printf("a>b = 1\tTherefore %d is greater",a);
else
printf("a>b = 0\tTherefore %d is greater",b);
}

void less()
{
int a,b;
printf("Enter two numbers to compare:");
scanf("%d%d",&a,&b);
if(a<b)
printf("a<b = 1\tTherefore %d is lesser",a);
else
printf("a<b = 0\tTherefore %d is lesser",b);
}

MAIT 128
void gequal()
{
int a,b;
printf("Enter two numbers to compare:");
scanf("%d%d",&a,&b);
if(a>=b)
printf("a>=b = 1\tTherefore they are equal or %d is greater than %d",a,b);
else
printf("a>=b = 0\tTherefore they are not equal or %d is not greater than %d",a,b);
}
void lequal()
{
int a,b;
printf("Enter two numbers to compare:");
scanf("%d%d",&a,&b);
if(a<=b)
printf("a<=b = 1\tTherefore they are equal or %d is lesser than %d",a,b);
else
printf("a<=b = 0\tTherefore they are not equal or %d is not lesser than %d",a,b);
}

void main()
{
int ch=0;
printf("\t\t\t\t\tUSAGE OF OPERATORS\n");
printf("1.Addition(-)\n2.Subtraction(-)\n3.Multiplication(*)\n4.Division(\\)\n5.Modulo
division(%)");
printf("\n6.Is equal to?(==)\n7.Is not equal to?(!=)\n8.Is greater than(>)\n9.Is less than(<)");
printf("\n10.Greater than or equal to(>=)\n11.Less than or equal to(<=)\n12.EXIT");
while(ch!=12)
{
printf("\nEnter your choice:");
scanf("%d",&ch);
switch(ch)
{
case 1 : add();break;
case 2 : subt();break;
case 3 : mult();break;
case 4 : divi();break;
case 5 : modu();break;
case 6 : equal();break;
case 7 : nequal();break;
case 8 : great();break;
case 9 : less();break;
case 10: gequal();break;
case 11: lequal();break;
case 12: break;

MAIT 129
default: printf("INVALID INPUT");

};
};
return 0;
}

Output:

MAIT 130
//57.TO CALCULATE SUM OF FIRST 25 PRIME NUMBERS
#include <stdio.h>
#include <conio.h>
int checkprime(int a)
{ int i,x=0;
i=a-1;
for( ;i!=1;i--)
{if(a%i==0)
{x++;
break;
};}
return x;}
void main()
{ int a=2,i=25,sum=0,y;
for( ;i>0 ; )
{
y=checkprime(a);
if(y==0)
{
sum=sum+a;
i--;
};
a++;
};
printf("\nSum=%d",sum);
return 0;

MAIT 131
Output:

MAIT 132
//58.TO CALCULATE FACTORIAL OF A NUMBER USING FUNCTION
#include <stdio.h>

int factorial(int a)
{ int i=a,fact=1;
while (i!=1)
{ fact=fact*i;
i--;
};
return fact;

void main()
{
int a,fact=1;
printf("\nEnter a number:");
scanf("%d",&a);
fact=factorial(a);
printf("\nFactorial=%d",fact);
return 0;

MAIT 133
Output:

MAIT 134
//59.TO CREATE A PROGRAM FOR SELECTION SORT
#include <stdio.h>
void main()
{
int arr[30],n,i=0,j=1,x,temp,t;
printf("Enter size of array:");
scanf("%d",&n);
printf("\nEnter elements of array:");
for( ;i<n ;i++ )
scanf("%d",&arr[i]);
for(i=0 ;i<n ;i++ )
{
x=arr[i];
t=-1;
for(j=i ;j<n ;j++ )
{
if(x<arr[j])
{
x=arr[j];
t=j;
}
}
if(t!=-1)
{
temp=arr[t];
arr[t]=arr[i];
arr[i]=temp;
};
}
printf("\nSorted array=");
for(i=0;i<n;i++)
printf("\n%d",arr[i]);
return 0;
}

MAIT 135
Output:

MAIT 136
//60.TO COUNT THE NUMBER OF EACH VOWEL IN A STRING
#include<stdio.h>
#include<string.h>
void main()
{char str[25];
int a=0,e=0,i=0,o=0,u=0,x;
printf("Enter a string to check:");
scanf("%s",str);
x=strlen(str);
for(int j=0 ;j<x ;j++ )
{
if(str[j]==97 || str[j]==65)
a++;
else if (str[j]==101 || str[j]==69)
e++;
else if (str[j]==105 || str[j]==73)
i++;
else if (str[j]==111 || str[j]==79)
o++;
else if (str[j]==117 || str[j]==85)
u++;
}
printf("\nNumber of a's=%d",a);
printf("\nNumber of e's=%d",e);
printf("\nNumber of i's=%d",i);
printf("\nNumber of o's=%d",o);
printf("\nNumber of u's=%d",u);
return 0;
}

MAIT 137
Output:

MAIT 138
MAIT 139
MAIT 140
MAIT 141

You might also like