Friday, October 14, 2011

Write a C program to print following sentences. a. I am an Indian b. “I am an Indian” c. *I am an Indian*

#include //This is include information about standard library
main() //User define function
{
printf("I am an Indian\n"); //here printing the given sentence
printf("*I am an Indian*\n"); //here printing the given sentence
printf("\"I am an Indian\"\n"); //here printing the given sentence
}

Define the structure called Batsman having properties like Batsman_ name,Batsman_country and Bats_avg .Using Batsman declare an array PLAYER with 11 elements and write a program to read the information of all the 11 Players and print Country wise list containing names of batsman with their batting averages.

#include
main()
{
struct Batsman
{
char Batsman_name[30];
char Batsman_country[10];
float Batsman_avg;
};

struct Batsman PLAYER[3];
char temp[1];
int i,j,k,l,m;
for (i=0;i<11;i++)
{
printf("Enter Batsman name: ");
gets(PLAYER[i].Batsman_name);
printf("Enter Batsman Country: ");
gets(PLAYER[i].Batsman_country);
printf("Enter Batsman Average: ");
scanf("%f",&PLAYER[i].Batsman_avg);
gets(temp);
}
for(j=0;j<11;j++)
{
m=0;
for(k=0;k if(strcmp(PLAYER[j].Batsman_country,PLAYER[k].Batsman_country)==0)
{
m++;
break;
}
if (m==0)
{
printf("\fCountry '%s' batsman are :-\n\n",PLAYER[j].Batsman_country);
for(l=0;l<11;l++)
if(strcmp(PLAYER[j].Batsman_country,PLAYER[l].Batsman_country)==0)
{
printf("%s\t",PLAYER[l].Batsman_name);
printf("%s\t",PLAYER[l].Batsman_country);
printf("%.4f",PLAYER[l].Batsman_avg);
printf("\n");
}
}
}

}
#include
main()
{
int i,n;
struct {
char emp_id[10];
char emp_name[10];
char emp_gen[10];
int emp_sal;
char email_add[30];
}
Employee[50];
for(i=0;i<10;i++)
{
printf("\n\nEnter Employee id:\t");
scanf("%s",Employee[i].emp_id);
printf("Enter Employee name:\t");
scanf("%s",Employee[i].emp_name);
printf("Enter Employee gender:\t");
scanf("%s",Employee[i].emp_gen);
printf("Enter Employee sal:\t");
scanf("%d",&Employee[i].emp_sal);
printf("Enter Employee email:\t");
scanf("%s",Employee[i].email_add);
}
for(i=0;i<10;i++)
{
printf("\n\nEmployee id : \t%s\n",Employee[i].emp_id);
printf("Employee name : \t%s\n",Employee[i].emp_name);
printf("Employee gender : \t%s\n",Employee[i].emp_gen);
printf("Employee salary : \t%d\n",Employee[i].emp_sal);
printf("Employee email : \t%s\n\n\n",Employee[i].email_add);
}
}

Define the structure called Employee having properties like emp_id, emp_name, gender, and emp_sal email_add. Write a program which takes the details of 10 employees.

#include
main()
{
int i,n;
struct {
char emp_id[10];
char emp_name[10];
char emp_gen[10];
int emp_sal;
char email_add[30];
}
Employee[50];
for(i=0;i<10;i++)
{
printf("\n\nEnter Employee id:\t");
scanf("%s",Employee[i].emp_id);
printf("Enter Employee name:\t");
scanf("%s",Employee[i].emp_name);
printf("Enter Employee gender:\t");
scanf("%s",Employee[i].emp_gen);
printf("Enter Employee sal:\t");
scanf("%d",&Employee[i].emp_sal);
printf("Enter Employee email:\t");
scanf("%s",Employee[i].email_add);
}
for(i=0;i<10;i++)
{
printf("\n\nEmployee id : \t%s\n",Employee[i].emp_id);
printf("Employee name : \t%s\n",Employee[i].emp_name);
printf("Employee gender : \t%s\n",Employee[i].emp_gen);
printf("Employee salary : \t%d\n",Employee[i].emp_sal);
printf("Employee email : \t%s\n\n\n",Employee[i].email_add);
}
}
#include
main()
{
int i,n;
struct {
char emp_id[10];
char emp_name[10];
char emp_gen[10];
int emp_sal;
char email_add[30];
}
Employee[50];
for(i=0;i<10;i++)
{
printf("\n\nEnter Employee id:\t");
scanf("%s",Employee[i].emp_id);
printf("Enter Employee name:\t");
scanf("%s",Employee[i].emp_name);
printf("Enter Employee gender:\t");
scanf("%s",Employee[i].emp_gen);
printf("Enter Employee sal:\t");
scanf("%d",&Employee[i].emp_sal);
printf("Enter Employee email:\t");
scanf("%s",Employee[i].email_add);
}
for(i=0;i<10;i++)
{
printf("\n\nEmployee id : \t%s\n",Employee[i].emp_id);
printf("Employee name : \t%s\n",Employee[i].emp_name);
printf("Employee gender : \t%s\n",Employee[i].emp_gen);
printf("Employee salary : \t%d\n",Employee[i].emp_sal);
printf("Employee email : \t%s\n\n\n",Employee[i].email_add);
}
}

Define the structure called CLASS having properties like stud_id, stud_name and stud_branch. Write a program which takes the details of at least 15 students.

main()
{
int i,n;
struct {
char stud_id[30];
char stud_name[30];
char stud_branch[30];
}
class[50];
printf("\nHow many students details would you want in the class(enter 15<) :\t");
scanf("%d",&n);
for(i=0;i {
printf("\n\nEnter student id:\t");
scanf("%s",class[i].stud_id);
printf("Enter student name:\t");
scanf("%s",class[i].stud_name);
printf("Enter student branch:\t");
scanf("%s",class[i].stud_branch);
}
printf("\n\n");
for(i=0;i {
printf("student id :\t\t %s\n",class[i].stud_id);
printf("student name :\t\t %s\n",class[i].stud_name);
printf("student branch :\t %s\n\n\n",class[i].stud_branch);
}
}

Write a function that calculates arithmetic addition, subtraction, multiplication and division of two integers?

#include
int addition(int x, int y)
{
int sum=x+y;
return sum;
}
int substraction(int x, int y)
{
int sub =x-y;
return sub;
}
int multiplication(int x, int y)
{
int mul =x*y;
return mul;
}
float division(float x,float y)
{
float div =(x/y);
return div;
}
main()
{
int a, b;
printf("\nEnter 1st integer:\t");
scanf("%d",&a);
printf("Enter 1st integer:\t");
scanf("%d",&b);
printf("\naddition :\t\t%d\n",addition(a,b));
printf("substraction :\t\t%d\n",substraction(a,b));
printf("multiplication :\t%d\n",multiplication(a,b));
printf("division :\t\t%.2f\n\n",division(a,b));
}

Write a function to obtain the prime factors of given number? For example, prime factors of 24 are 2,2,2 and 3, whereas prime factors of 35 are 5 and 7

#include
pri_fact(int n)
{
int i;
for(i=2;i<=n;i++)
{
if(n%i==0)
{
printf("%d ",i);
pri_fact(n/i);
break;
}
}
}
main()
{
int n;
printf("\nEnter an integer :\t");
scanf("%d",&n);
printf("\n");
pri_fact(n);
printf("\n\n");
}

Write a function which receives a float and an int from main (), finds the product of these two numbers and returns the product which is printed through main()?

#include
float product(int a,float b)
{
float c;
c=a*b;
return c;
}
main()
{
int x;
float y;
printf("\nEnter an integer :\t");
scanf("%d" ,&x);
printf("Enter a float :\t\t");
scanf("%f",&y);
printf("product :\t\t%.2f\n\n",product(x,y));
}

Write a function that calculates Area and Perimeter/ Circumference of the Circle, whose radius is entered through the keyboard?

#include
#define pi 3.14
float perimeter(float k)
{
float p=2*pi*k;
return p;
}
float area(float k)
{
float a =pi*k*k;
return a;
}
main()
{
float r;
printf("\nEnter radius of cicle:\t\t");
scanf("%f",&r);
printf("Perimeter/circumference :\t%.2f\n",perimeter(r));
printf("Area of the circle is :\t\t%.2f\n\n",area(r));
}

Write a C program to find character frequency in a given string? Example: given Input is: I AM AN INDIAN


#include
main()
{
char s[100], ch;
int count= 0, n[26]={0},temp,i;
printf("Enter a string\t:");
gets(s);
printf("Character\t\tFreequency");
printf("\n---------\t\t----------\n");
for (i=0;i<26;i++) { temp=s[i]; if (temp>=65 && temp<=90)
{
temp+=32;
s[i]=temp;
}
else
s[i]=temp;
}

while(s[count]!='\0')
{
n[s[count]-'a']++;
count++;
}
for (count=0;count<26;count++ )
{
if( n[count] != 0 )
printf(" %c\t\t\t %d\n",count+'a',n[count]);
}
}

Write a program to do the following: a. Output of the question is: Who was the winner of 2007 cricket world cup? b. Accept answer c. If answer is correct print good and stop otherwise give output message as answer is wrong, so try again. d. Display the correct answer when the answer is wrong even at the third attempt.

#include
#include
main()
{
int i=1;
do
{
char a[100];
printf("Who is the winner of 2007 cricket world cup\t:");
scanf("%s",a);
if (strcmp(a,"australia")==0||strcmp(a,"AUSTRALIA")==0||strcmp(a,"Australia")==0)
{
printf("Right Answer\n");
break;
}
else if(i<=2 && strcmp(a,"australia")!=0 && strcmp(a,"AUSTRALIA")!=0&&strcmp(a,"Australia")!=0)
printf("Sorry,Wrong Anser try again\n");
else if(i==3 && strcmp(a,"australia")!=0 && strcmp(a,"AUSTRALIA")!=0&&strcmp(a,"Australia")!=0)
{printf("\nThis time also you entered wrong answer\n\n");
printf("\n\t\t\tCorrect Answer is : Australia \n\n");
}
}
while(i++ && i<4);
}

Write a C program to find how many times given substring is exist ?

#include
main()
{
int i=0,j=0,k=0,count=0,l=0,m=0;
char a[100],b[100];
printf("\nEnter the string \t:");
gets(a);
printf("\nEnter sub string \t:");
gets(b);
l=strlen(b);
while (a[i]!=EOF)
{
if (a[i]==b[j])
{
i++;
j++;
m=1;

if (j==l)
{
j=0;
k=1;
count=count+1;
}
}
else
{
if (m==1)
{
j=0;
m=0;
}
else
i++;
}
}

if (k==1)
{
printf("\n\nThe Entered sub string is present in the given string\n\n");
printf("\nIt is present %d times in the given string\n\n",count);
}
else
{
if (k==0)
printf("\n\nThe Entered sub string is not present in the given string\n\n");
}
}

Write the following C Programs without string functions? a. Length of a string b. Reverse of a string c. String Concatenation d. String comparison e. String copy

#include
#include
main()
{
printf("\t\t1.Length of a string\n");
printf("\t\t2.Reverse of a string\n");
printf("\t\t3.String Concatenation\n");
printf("\t\t4.String comparison\n");
printf("\t\t5.String copy\n\n");
int o,i;
char string[500],a[100],b[100],c;
printf("Select a option from the above list:-\t");
scanf("%d",&o);
switch(o)
{
case 1:
{
printf("\n\t=============================>a.Length of a string<==============================================\n"); printf("Enter a string\t:"); scanf("%s",&string); i=0; while (string[i]!='\0') i++; printf("string length\t:%d\n",i); break; } case 2: { printf("\n\t=============================>b.Reverse of a string<==============================================\n"); printf("Enter a string\t\t\t:\t"); scanf("%s",&a); reverse(a); printf("Reverse of entered string is :\t%s\t\n",a); break; } case 3: { printf("\n\t=============================>c.String Concatenation<==============================================\n"); printf("Enter first string to concatenate :\t"); scanf("%s",&a); printf("Enter second string to concatenate :\t"); scanf("%s",&b); concat(a,b); printf("After concatenation String is :\t%s\n", a); break; } case 4: { printf("\n\t=============================>d.String comparison<==============================================\n"); printf("Enter the first string :\t"); scanf("%s",&a); printf("Enter the second string :\t"); scanf("%s",&b); c= compare(a,b); if (c == 0) printf("Both Entered strings are same.\n"); else printf("Entered strings are not equal.\n"); break; } case 5: { printf("\n\t=============================>e.String copy<==============================================\n");
printf("Enter a string :\t");
scanf("%s",&a);
copy(b, a);
printf("copied string :\t%s\n", b);
break;
}
default:
{
printf("\nChoose the right option which is with in the range 1-5 only \n\n");
}
}
}
reverse(char*);
reverse(char *a)
{
int l, i;
char *begin, *end, temp;
l = strlen(a);
begin = a;
end = a;
for (i=0;i<(l-1);i++)
end++;
for (i=0;i {
temp = *end;
*end = *begin;
*begin = temp;
begin++;
end--;
}
}
concat(char*, char*);
concat(char *a, char *b)
{
while(*a)
a++;
while(*b)
{
*a = *b;
b++;
a++;
}
*a = '\0';
}
int compare(char *a, char *b)
{
while(*a)
{
if(*a == *b)
{
a++;
b++;
}
else
return -1;
}
}
copy(char*, char*);
copy(char *b, char *a)
{
while(*a)
{
*b = *a;
a++;
b++;
}
*b = '\0';
}

Write a C program to find number of pairs of adjacent numbers whose sum is 8 in a given list of items? (Example : i/p: 2 4 5 3 1 7 1 7 4 5 output: 4 )

#include
int main()
{
int l[10],a,b,c=0,s;
printf("Enter the size of array You want :-");
scanf("%d",&a);
printf("Enter the elements in the array :-\n");
for(b=0;b {
scanf("%d",&l[b]);
}
printf("\nThe elements in the array are :-");
for(b=0;b {
printf(" %d",l[b]);
}
printf("\n");
printf("Enter your sum number :-");
scanf("%d",&s);
for(b=0;b {
if (l[b]+l[b+1]==s)
c=c+1;
}
printf("Adjacent numbers whose sum is \'%d\' having pairs are : \'%d\'\n",s,c);
}

Write a C program to find a. Addition of two matrices b. Multiplication of two matrices. c. Trace of a matrix d. Transpose of matrix

#include
main()
{
printf("\t\t1.Addition of two matrices\n");
printf("\t\t2.Multiplication of two matrices.\n");
printf("\t\t3.Trace of a matrix\n");
printf("\t\t4.Transpose of matrix\n");
int a[10][10],b[10][10],c[10][10],i,j,k,sum=0,m,n,o,p,s;
printf("Select a option from the above list: \t");
scanf("%d",&s);
switch(s)
{
case 1:
printf("\n\t\t=============================>a.Addition of two matrices<==============================================\n"); printf("\n\t ***For the addition Enter the same same size of matrix*** \n"); printf("\nEnter rows and columns of the first matrix:\n"); scanf("%d %d",&m,&n); printf("\nEnter rows and columns of the second matrix:\n"); scanf("%d %d",&o,&p); printf("\nEnter the elements here for first matrix:\n"); for(i=0;ib.Multiplication of two matrices<==============================================\n"); printf("\nEnter rows and columns of the first matrix:\n"); scanf("%d %d",&m,&n); printf("\nEnter rows and columns of the second matrix:\n"); scanf("%d %d",&o,&p); if(n!=o) { printf("\nMatrix mutiplication is not possible\n"); printf("***First matrix columns are equal to second matrix rows***"); } printf("\nEnter the elements here for first matrix:\n"); for(i=0;ic.Trace of a matrix<==============================================\n"); printf("\nEnter rows and columns of the matrix:\n"); scanf("%d %d",&m,&n); printf("\nEnter the elements here for first matrix:\n"); for(i=0;id.Transpose of matrix<==============================================\n");
printf("\nEnter rows and columns of the matrix:\n");
scanf("%d %d",&m,&n);
printf("\nEnter the elements here for first matrix:\n");
for(i=0;i for(j=0;j scanf("%d",&a[i][j]);
printf("\nThe real matrix is :\n");
for(i=0;i {
printf("\n");
for(j=0;j {
printf("%d\t",a[i][j]);
}
}
printf("\n\n");
for(i=0;i for(j=0;j b[i][j]=0;
for(i=0;i {
for(j=0;j {
b[i][j]=a[j][i];
}
}
printf("\nTraspose of matrix is :\n\t");
for(i=0;i {
printf("\n");
for(j=0;j {
printf("%d\t",b[i][j]);
}
}
printf("\n\n");
break;

default :
printf("\n Choose the right option which is with in the range 1-4 only \n\n");
break;
}
}

Write a C program to generate and print the first N Fibonacci num

#include
int fib(int);
main()
{
int n;
printf("Enter N value:");
scanf("%d",&n);
fib(n);
}
int fib(int n)
{
int a=0,b=1,c;
printf("%d %d ",a,b);
while(n>0)
{
c=b+a;
printf("%d ",c);
a=b;
b=c;
n-=1;
}
printf("\n");

}

Write a C program to find following parameters for given list of elements? a. Max b. Min c. Mode d. Variance e. Standard deviation

#include

#include

main()
{
printf("\t\t1.Max\n");
printf("\t\t2.Min\n");
printf("\t\t3.Mode\n");
printf("\t\t4.Variance\n");
printf("\t\t5.Standard deviation\n\n");
int c,a[20],min,max,i,j,n,s=0,k,l,tv,mode=0,count=0,mx=0;
float x,y=0,std,z=0;
printf("Select a option from the above list:-\t");
scanf("%d",&c);
switch(c)
{
case 1:
printf("\n\t=============================>a.Max(Maximum value)<==============================================\n"); printf("Enter the No of Elements You want :\t"); scanf("%d",&n); printf("Enter the Elements You want :\n"); for(i=0;imax)
max=a[i];
}
printf("Maximum value = %d \n",max);
break;
case 2:
printf("\n\t=============================>a.Min(Minimum value)<==============================================\n"); printf("Enter the num of Elements You want :\t"); scanf("%d",&n); printf("Enter the Elements You want :\n"); for(i=0;imax)
max=a[i];
}
printf("Minimum value = %d \n",min);
break;
case 3:
("\n\t=============================>c.Mode(Mode value)<==============================================\n"); printf("Enter the num of Elements You want :\t"); scanf("%d",&n); printf("Enter the Elements You want :\n"); for(i=0;ia[j+1])
{
tv=a[j];
a[j]=a[j+1];
a[j+1]=tv;
}
}
}
for(l=0;lmx)
{
mx=count;
mode=a[l];
}
}
printf("Mode = %d \n",mode);
break;
case 4:
("\n\t=============================>d.Variance<==============================================\n"); printf("Enter the num of Elements You want :\t"); scanf("%d",&n); printf("Enter the Elements You want :\n"); for(i=0;ie. Standard deviation<==============================================\n");
printf("Enter the num of Elements You want : \t");
scanf("%d",&n);
printf("Enter the Elements You want : \n");
for(i=0;i {
scanf("%d",&a[i]);
s=s+a[i];
}
k=s/n;
for(i=0;i {
y=y+pow((a[i]-k),2);
}
z=y/n;
std=sqrt(z);
printf("Standard deviation : %f\n\n",std);
break;
default :
printf("\n Choose the right option which is with in the range 1-5 only \n\n");
}
}

Write a C program to find given element in a list or not.(linear search)?

#include
main()
{
int a,b,c,d,e=0;
printf("\nEnter the length of your list = ");
scanf("%d",&a);
int list[a];
for (b=1;b<=a;b++)
{
printf("\nElement%d:",b);
scanf("%d",&list[b]);
}
printf("\nEnter a Element you want search:\t");
scanf("%d",&c);
for (d=1;d<=a;d++)
{
if (list[d]==c)
e=e+1;
}
if (e==0)
printf("*****The given input element not found*****");
else
printf("\nThe given element present %d time(s) in the list.\n",e);
}

Start with a positive integer n. If n is even, divide it by 2, else replace n by 3n+1. Repeat until we obtain the value 1 in the sequence. The 3x+1 conjecture says that we eventually reach 1 irrespective of what initial value of n we start with. Different initial values of n lead to different numbers of iterations of the loop before hitting the value 1. For example, if we start with n=3, we get a sequence 3,10,5,16,8,4,2,1 using 7 iterations. If we start with 7, we need 16 iterations, since the sequence is now 7,22,11,34,17,52,26,13,40,20,10,5,16,8,4,2,1. You are given a bound B. Your task is to locate that particular value of n in the range 1<=n<=B for which the number of iterations is maximum. Once this integer nis located, you print n, the corresponding number of iterations, and finally the sequence associated with n. If the bound is 10, then the output of your program would look like: Maximum number of iterations = 19 for n = 9. The sequence is: 9 28 14 7 22 11 34 17 52 26 13 40 20 10 5 16 8 4 2 1 Report the output of your program for the bound 100,000.

#include
main()
{
int a,b,c,d,e,f=0,g=0,h=0;
printf("Enter your Bound :\t");
scanf("%d",&a);
for(b=1;b<=a;b++)
{
c=b;
f=0;
d=b;
while(c!=1)
{
if(c%2==0)
{
c=c/2;
f=f+1;
}
else
{
c=(3*c)+1;
f=f+1;
}
}
if(g {
g=f;
e=d;
}
}
printf("Maximum number of iterations = %d for n=%d\n",g,e);
printf("The sequence is : %d\n",e);
while(e!=1)
{
if(e%2==0)
{
e=e/2;
h=h+1;
printf("%d ",e);
}
else
{
e=(3*e)+1;
h=h+1;
printf("%d ",e);
}
}
printf("\n");
}

Write a C program to reverse a given four-digit number and check whether the number is a palindrome or not. Note:A palindrome is a word, phrase, number or other sequence of units that can be read the same way in either direction Ex: MADAM, LEVEL, POP, RADAR etc...

#include
int main()
{
int a,b,c=0,d;
printf("\tEnter a number u want:"); //USER INPUT
scanf("%d",&a);
d=a;
while(a)
{
b=a%10;
a=a/10;
c=c*10+b;
}
printf("\tReverse number is :%d\n",c); //printing of reverse number
if(d==c)
printf("\t%d is a palindrome\n",d); //prints if polyndrome
else
printf("\t%d is not a palindrome\n",d); //prints if not polyndrome
}

Write a C program to find the GCD and LCM of two given integers, and output the results.

#include
main()
{
int a,b,gcd,lcm,r,m=0,i;
printf("Enter two numbers you want :>\n"); //user input
scanf("%d %d",&a,&b);
if (a m=a;
else
m=b;
for (i=1;i<=m;i++)
{
if (a%i==0&&b%i==0)
gcd=i;
}
r=a*b;
lcm=r/gcd;
printf("GCD of the given two numbers= %d",gcd); //printing GCD of given two numbers
printf("\nLCM of the given two numbers= %d\n",lcm); //printing LCM of given two numbers

}

Write a C program to generate and print the first N Fibonacci numbers.

#include
main()
{
int a=0,b=1,c,n,d=0;
printf("Enter the value of N :");
scanf("%d",&n);
printf("%d Fibanocci numbers are :\n",n);
printf("%d\n",a);
printf("%d\n",b);
d=2; /*'0'and'1'are already used*/
while (d {
c=a+b;
d++;
printf("%d\n",c);
a=b;
b=c;
}
}

Write a C program to print the given alphabet pyramids.




#include
main()
{
int i,j,k,s,v;
printf("Enter 1 or 2 for structure:\t"); //number for switch case
scanf("%d",&s);
printf("Enter number for Pyramid size:\t"); //takes zize(Height) of pyramid
scanf("%d",&v);
switch(s) /*Switch case to select one structure from the two structures*/
{
case 1:
for (j=v;j>0;j--)
{
for (i=1;i0;i--)
printf("%d ",i);
printf("\n");
}
break;
case 2:
for (j=v;j>0;j--)
{
for (k=v-j;k>0;k--)
printf(" ");
for (i=1;i<=j;i++) printf("%d ",i); for (i=j-1;i>0;i--)
printf("%d ",i);
for (k=v-j;k>0;k--)
printf(" ");
printf("\n");
}
break;
default:
printf("****Enter 1 or 2 only for structure****\n");
}
}

Write a C program to find following parameters for known 3 numbers. a. Sum b. Average c. Min d. Max e. Variance f. Standard deviation

#include<stdio.h>
#include<math.h>
main()
{
    int a,b,c;
    float sum,avg,variance,sd;
    printf("Enter a value for first number\t:");
    scanf("%d",&a);
    printf("Enter a value for second number\t:");
    scanf("%d",&b);
    printf("Enter a value for third number\t:");
    scanf("%d",&c);
/*a.sum*/
    sum=a+b+c;
    printf("\n\ta.Sum:%.2f\n",sum);
/*b.Average*/   
    avg=sum/3;
    printf("\n\tb.Average:%.2f\n",avg);
/*c.Min*/
    if(a<b)
            {
                if(a<c)
                printf("\n\tc.Min:%d",a);
                else
                printf("\n\tc.Min:%d",c);               
            }
            else
            {
                if(b<c)
                printf("\n\tc.Min:%d",b);
                else
                printf("\n\tc.Min:%d",c);
            }
/*d.Max*/
    if(a>b)
            {
                if(a>c)
                printf("\n\td.Max:%d",a);
                else
                printf("\n\td.Max:%d",c);               
            }
            else
            {
                if(b>c)
                printf("\n\td.Max:%d",b);
                else
                printf("\n\td.Max:%d",c);
            }
/*e.Variance*/
    variance=(pow((a-avg),2)+pow((b-avg),2)+pow((c-avg),2))/3;
    printf("\n\te.Variance:%.2f\n",variance);
/*f.Standard deviation*/
    sd=sqrt(variance);
    printf("\n\tf.Standard Deviation:%.2f\n",sd);
           
}

Write C program to print a. Integers from 1-100 b. Even numbers from 1-100 c. Odd numbers from 1-100

#include<stdio.h>
main()
{
    int a,b,c;
    printf("\n\n\t a.Integers from 1-100 \n\n");
    for (a=1;a<=100;a++)
    {
        printf(" %d",a);
    }
    printf("\n\n\t b.Even numbers from 1-100\n\n");
    for (b=1;b<=100;b++)
    {    if (b%2==0)
        printf(" %d",b);
    }
    printf("\n\n\t c.Odd numbers from 1-100\n\n");
    for (c=1;c<=100;c++)
    {    if (c%2!=0)
        printf("%d ",c);
    }
    printf("\n");
}

Write a C program to find the roots of a quadratic equation.

#include<stdio.h>
#include<math.h>
main()
{
    float a,b,c,r1,r2;
    printf("Enter values for a,b,c for finding the roots of quadratic equation:\n");
    scanf("%f%f%f",&a,&b,&c);
    if(b*b>4*a*c)
    {
        r1=(-b+sqrt(b*b>4*a*c))/(2*a);
        r2=(-b-sqrt(b*b>4*a*c))/(2*a);
        printf("root1=%f\nroot2=%f\n",r1,r2);
    }
    else
    printf("Imaginary roots");
}

A rectangle with sides parallel to the X- and Y-axes is specified by four real numbers a, b, c, and d. Assume that a <= c and b <= d. The four corners of the rectangle are (a,b) [bottom left], (c,b) [bottom right], (a,d) [top left], and (c,d) [top right]. Read the values a1, b1, c1, and d1 from the user for a rectangle R1. Subsequently, read the values a2, b2, c2, and d2 for another rectangle R2. Your task is to determine whether the two rectangles R1 and R2 intersect. To solve this problem, it suffices to check whether both the following conditions are satisfied: * The interval [a1, c1] has an overlap with the interval [a2, c2]. * The interval [b1, d1] has an overlap with the interval [b2, d2]. Two real intervals I = [s,t] and J = [u,v] operlap if and only if I starts before J ends and J starts before I ends, that is, if and only if s <= v and u <= t. Report the output of your program for the following four runs. a1, b1, c1, d1 a2, b2, c2, d2 1, 2, 3, 4 2, 3, 4, 5 1, 2, 3, 4 3, 4, 5, 6 1, 2, 3, 4 4, 5, 6, 7 1, 2, 3, 4 1.5, 5, 2.5, 6

main()
{
    int a,b,c,d,a1,b1,c1,d1;
    printf("enter the value of a1\t=");
    scanf("%d",&a);
    printf("enter the value of b1\t=");
    scanf("%d",&b);
    printf("enter the value of c1\t=");
    scanf("%d",&c);
    printf("enter the value of d1\t=");
    scanf("%d",&d);
    printf("enter the value of a2\t=");
    scanf("%d",&a1);
    printf("enter the value of b2\t=");
    scanf("%d",&b1);
    printf("enter the value of c2\t=");
    scanf("%d",&c1);
    printf("enter the value of d2\t=");
    scanf("%d",&d1);
    if(((a<a1)&(a1<c))&&((b<b1)&(b1<d)))
    {
        printf("***********The given rectangles are overlap each other*************\n");
    }
    else
    {
        printf("*****not overlap*****\n");
    }
}

Write a C program to calculate the following Sum: Sum=1-x2/2! +x4/4!-x6/6!+x8/8!-x10/10!

#include<stdio.h>
#include<math.h>
main()
{
    float x,a=1,b=1,c,d,e,f,g,h;
    printf("Enter a variable you want\t:");
    scanf("%f",&x);
    for(a=1;a<=10;a++)
    {
        b=b*a;
        if(a==2)
            c=b;
        if(a==4)
            d=b;
        if(a==6)
            e=b;
        if(a==8)
            f=b;
        if(a==10)
            g=b;
    }
    h=1-((pow(x,2))/c)+((pow(x,4))/d)-((pow(x,6))/e)+((pow(x,8))/f)-((pow(x,10))/g);
    printf("%f\n",h);
   
   
}

Write a C program to find the Area and perimeter of a. Circle Input: r (radius) b. Square Input: a (length of side) c. Triangle Inputs: a, b, c (a, b, c are 3 sides of a triangle) d. Rectangle Input: l, b (l=length & b= breadth) e. Ellipse Input: a, b (a=major axes, b=minor axes)

#include <stdio.h>            //This is include information about standard library
#include <math.h>            //math function includes about math commands
main()                    //User define function
{

//circle
float pi=3.14,r,a,b,c;            //Float funcion which takes all float values
printf("Enter the value for r: ");    //which asks the user input
scanf("%f",&r);                //which attach the user input to r variable
a=pow(r,2);                //a variable equals to r sqare using pow function
b=pi*a;                    //formula for circle area
c=2*pi*r;                //formula for circle perimeter
printf("Circle area :%f\n",b);        //printing circle area
printf("perimeter :%f\n",c);        //printing circle perimeter


//square
float d,e,f;                //Float funcion which takes all float values
printf("Enter the value for a: ");    //which asks the user input
scanf("%f",&d);                //which attach the user input to a variable
e=pow(d,2);                //formula for area of square
f=4*d;                    //formula for perimeter of square
printf("Square area :%f\n",e);        //prints area of square
printf("Square perimeter :%f\n",f);    //prints perimeter of square


//triangle
float g,h,i,j,k,l;                //Float funcion which takes all float values
printf("Enter the value for side a: ");        //user input for side a
scanf("%f",&g);                    //which attaches the user input to a variable a
printf("Enter the value for side b: ");        //user input for side b
scanf("%f",&h);                    //which attaches the user input to a variable b
printf("Enter the value for side c: ");        //user input for side c
scanf("%f",&i);                    //which attaches the user input to a variable c
l=(g+h+i)/2;                   
j=sqrt(l*(l-g)*(l-h)*(l-i));            //formula for triangle area
printf("Triangle area :%f\n",j);        //printing the triangle area
k=g+h+i;                        //formula for triangle perimeter
printf("Triangle perimeter :%f\n",k);        //printing the triangle perimeter


//rectangle
float m,n,o,p;                    //Float funcion which takes all float values
printf("Enter the value for length l: ");    //which takes the valuse for length from user input
scanf("%f",&m);                    //which attaches the user input to variable l
printf("Enter the value for bredth b: ");    //which takes the valuse for bredths from user input
scanf("%f",&n);                    //which attaches the user input to variable b
o=m*n;                        //formula for rectangle area
p=2*(m+n);                    //formula for rectangle perimeter
printf("Rectangle area :%f\n",o);        //prints rectangle area
printf("perimeter :%f\n",p);            //prints rectangle perimeter


//ellipse
float u=3.14,q,v,s,t;                //Float funcion which takes all float values
printf("Enter the value for major axis a: ");    //which takes value for the major axis from the userinput
scanf("%f",&q);                    //which attach the user input to a variable a
printf("Enter the value for minor axis b: ");    //which asks the user input for the minor axis
scanf("%f",&v);                    //which attach the user input to a variable b
s=u*q*v;                    //formula for Ellipse area
t=2*u*sqrt((pow(q,2)+pow(v,2))/2);        //formula for Ellipse perimeter
printf("Ellipse area :%f\n",s);            //printing Ellipse area
printf("Ellipse perimeter :%f\n",t);        //printing Ellipse perimeter
}

Write a C program to generate all the prime numbers between 1 and n, where n is a positive integer

#include //This is include information about standard library
main() //User define function
{
int n,a,b,c; //int funcion which takes all integer values
printf("Enter n value :"); //printing statement
scanf("%d",&n); //attaching the user input to the variable
c=0; //taking a variable as zero
for(a=1;n>=a;a++) //for loop for take the range to the user input
{ for(b=1;a>=b;b++) //for loop for printing the all prime numbers up to user input number
{ if(a%b==0) //if a%b is equal to zero
c=c+1; //incrimenting the value
}
if (c==2) //if c is equal to 2
{
printf("%d",a); //printing primenumbers upto given number
printf("\n");
c=0;
}
else //else statement
{
c=0; //stops the program
}
}
}

Write a C program to find the sum, multiplication, division, subtraction of individual digits of a positive integer.

#include //This is include information about standard library
main() //User define function
{
int n,a=0,b,c=1; //int funcion which takes all integer values in the program
float d=1,e=0; //float function which takes all float values in the program
printf ("Enter a number(contains atleast two digits):"); //printing statement
scanf ("%d",&n); //attaching the user input to the variable
while (n!=0)
{
b=n%10; // % of given number with 10
a=a+b; //summation of the digits in the integer
c=c*b; //multiplication of th digits in the integer
d=b/d; //division of the digits in the integer
e=b-e; //substraction of the digits in the integer
n=n/10;
}
printf ("summation of the digits in the number :%d\n",a); //prints summation of the digits in the given integer
printf ("multiplication of the digits in the number :%d\n",c); //prints multiplication of th digits in the given integer
printf ("division of the digits in the number :%f\n",d); //prints division of the digits in the given integer
printf ("substraction of the digits in the number :%f\n",e); //substraction of the digits in the given integer
}