0% found this document useful (0 votes)
3 views8 pages

AI & DS C PROGRAM

The document contains multiple C programs that perform various tasks including calculating the sum, average, and standard deviation of numbers, finding prime numbers within a range, generating a Fibonacci series, sorting numbers in ascending order, and counting vowels in a string. Each program is structured with input prompts, processing logic, and output statements. The programs utilize standard libraries and basic control structures to achieve their respective functionalities.
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)
3 views8 pages

AI & DS C PROGRAM

The document contains multiple C programs that perform various tasks including calculating the sum, average, and standard deviation of numbers, finding prime numbers within a range, generating a Fibonacci series, sorting numbers in ascending order, and counting vowels in a string. Each program is structured with input prompts, processing logic, and output statements. The programs utilize standard libraries and basic control structures to achieve their respective functionalities.
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

SUM,AVERAGE AND STANDARD DEVIATION

PROGRAM :

#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
float x[50];
int i,n;
float sum,mean,sd;
clrscr();
printf("\n\t\t\t SUM,AVERAGE AND STANDARD DEVIATION ");
printf("\n\t\t\t ================================== ");
printf("\n\t ENTER THE LIMIT : ");
scanf("%d",&n);
printf("\n\t ENTER %d NUMBERS : \n",n);
for(i=0;i<n;i++)
scanf("%f",&x[i]);
sum=0.0;
for(i=0;i<n;i++)
sum+=x[i];
mean=sum/n;
printf("\n\t\t THE SUM OF GIVEN NUMBERS =%6.3f ",sum);
sum=0.0;
for(i=0;i<n;i++)
sum+=(x[i]-mean)*(x[i]-mean);
sd=sqrt(sum/n);
printf("\n\n\t\t THE MEAN VALUE OF GIVEN NUMBERS = %6.3f\n",mean);
printf("\n\t\t THE STANDARD DEVIATION OF GIVEN NUMBERS IS = %6.3f\n",sd);
getch();
}
OUTPUT:
[Link] NUMBERS
#include <stdio.h>
#include<conio.h>
void main()
{
int m, n, i, flag;
clrscr();
printf("\n\t PRIME NUMBERS \n\t ***** *******");
printf("\n ENTER THE STARTING NUMBER : ");
scanf("%d",&m);
printf("\n ENTER THE ENDING NUMBER : ");
scanf("%d",&n);
printf("\n PRIME NUMBERS BETWEEN %d AND %d : " ,m,n);
while (m < n)
{
flag = 0;
for(i = 2; i <= m/2; ++i)
{
if(m % i == 0)
{
flag = 1;
break;
}
}
if (flag == 0)
printf("%d ", m);
++m;
}
printf("\n");
getch();
}
OUTPUT:
[Link] SERIES
PROGRAM:

#include<stdio.h>
#include<conio.h>
int fibonacci(int);
void main()
{
int n, i;
clrscr();
printf("\n\t FIBONACCI SERIES ");
printf("\n\t ~~~~~~~~~~~~~~~~~ ");
printf("\n\t\t ENTER THE LIMIT : ");
scanf("%d",&n);
printf("\n\n\t FIBONACCI SERIES IS : ");
for(i=0;i<n;i++)
{
printf("%d ",fibonacci(i));
}
getch();
}
int fibonacci(int i)
{
if(i==0)
return 0;
else if(i==1)
return 1;
else
return (fibonacci(i-1)+fibonacci(i-2));
}

OUTPUT:
[Link] ORDER
PROGRAM:
#include <stdio.h>
#include<conio.h>
int main()
{
int n, data[10],i,j,temp;
clrscr();
printf("\n\t\t ASCENDING ORDER ");
printf("\n\t\t =============== ");
printf("\n\n\t\t ENTER THE LIMIT : ");
scanf("%d", &n);
printf("\n\t ENTER THE %d NUMBERS : ",n);
for (i = 0; i < n; i++)
scanf("%d", &data[i]);
printf("\n\n\t THE GIVEN NUMBERS BEFORE SORTING ");
printf("\n\t ================================ \n");
for (i = 0; i < n; i++)
printf("\t%d", data[i]);
for (i = 0; i < n-1; i++)
{
for (j = i + 1; j < n; j++)
{
if (data[i] > data[j])
{
temp = data[i];
data[i] = data[j];
data[j] = temp;
}
}
}
printf("\n\n\t THE GIVEN NUMBERS AFTER SORTING ");
printf("\n\t ******************************* \n");
for (i = 0; i < n; i++)
printf("\t%d", data[i]);
getch();
return 0;
}
OUTPUT:
[Link] OF VOWELS
PROGRAM:

#include <stdio.h>
#include<conio.h>
void main()
{
int c = 0, count = 0;
char s[1000];
clrscr();
printf("\n\t\t\t VOWELS COUNTING ");
printf("\n\t\t\t ~~~~~~~~~~~~~~~ ");
printf("\n\t ENTER THE STRING TO FIND THE VOWELS : ");
gets(s);
while (s[c] != '\0')
{
if (s[c] == 'a' || s[c] == 'A' || s[c] == 'e' || s[c] == 'E' || s[c] == 'i' || s[c] == 'I' || s[c] =='o' ||
s[c]=='O' || s[c] == 'u' || s[c] == 'U')
count++;
c++;
}
printf("\n\n\t\t TOTAL NUMBER OF VOWELS IN THE GIVEN STRING : %d", count);
getch();
}

OUTPUT:

You might also like