Sunday, 30 August 2015

Write a C function using pointers to add two matrices and to return the resultant matrix to the calling function

Write a C function using pointers to add two matrices and to return the resultant matrix to the calling function
1:  #include<stdio.h>  
2:  #include<conio.h>  
3:  int a[5][5],b[5][5],row,col;  
4:  void add(int(*)[5]);  
5:  int main()  
6:  {  
7:        int c[5][5],i,j;  
8:        clrscr();  
9:        printf("Enter row : ");  
10:        scanf("%d",&row);  
11:        printf("Enter column : ");  
12:        scanf("%d",&col);  
13:        printf("Enter matrix A :\n");  
14:        for(i=0;i<row;i++)  
15:        {  
16:              for(j=0;j<col;j++)  
17:              {  
18:                    scanf("%d",&a[i][j]);  
19:              }  
20:        }  
21:        printf("Enter matrix B :\n");  
22:        for(i=0;i<row;i++)  
23:        {  
24:              for(j=0;j<col;j++)  
25:              {  
26:                    scanf("%d",&b[i][j]);  
27:              }  
28:        }  
29:        add(c);  
30:        printf("Addition :\n");  
31:        for(i=0;i<row;i++)  
32:        {  
33:              for(j=0;j<col;j++)  
34:              {  
35:                    printf("%d\t",c[i][j]);  
36:              }  
37:              printf("\n");  
38:        }  
39:        getch();  
40:        return 0;  
41:  }  
42:  void add(int c[5][5])  
43:  {  
44:        int i,j;  
45:        for(i=0;i<row;i++)  
46:        {  
47:              for(j=0;j<col;j++)  
48:              {  
49:                    c[i][j]=a[i][j]+b[i][j];  
50:              }  
51:        }  
52:  }  

Write a C function to calculate the roots of the quadratic equation. The function must use two pointer parameters, one to receive the coefficients a, b, and c, and the other to send the roots to the calling function

Write a C function to calculate the roots of the quadratic equation. The function must use two pointer parameters, one to receive the coefficients a, b, and c, and the other to send the roots to the calling function Write a C function to calculate the roots of the quadratic equation. The function must use two pointer parameters, one to receive the coefficients a, b, and c, and the other to send the roots to the calling function
1:  #include<stdio.h>  
2:  #include<conio.h>  
3:  void solve(int*,float*);  
4:  int main()  
5:  {  
6:        int a[3];  
7:        float *root;  
8:        clrscr();  
9:        printf("Enter the value of A : ");  
10:        scanf("%d",&a[0]);  
11:        printf("Enter the value of B : ");  
12:        scanf("%d",&a[1]);  
13:        printf("Enter the value of C : ");  
14:        scanf("%d",&a[2]);  
15:        solve(a,root);  
16:        if(root==NULL)  
17:              printf("The root is not possible\n");  
18:        else if(root[0]==root[1])  
19:              printf("The root is %.2f\n",root[0]);  
20:        else  
21:              printf("The roots are %.2f & %.2f\n",root[0],root[1]);  
22:        getch();  
23:        return 0;  
24:  }  
25:  void solve(int *a,float *r)  
26:  {  
27:        float d;  
28:        d=a[1]*a[1]-4*a[0]*a[2];  
29:        if(d<0)  
30:        {  
31:              r=NULL;  
32:        }  
33:        else if(d==0)  
34:        {  
35:              r[0]=r[1]=-a[1]/(2*a[0]);  
36:        }  
37:        else  
38:        {  
39:              r[0]=-a[1]/(2*a[0]);  
40:              r[1]=-a[1]/(2*a[0]);  
41:        }  
42:  }  

Write a C Program using pointers to read an array of integers and print its elements in reverse order

Write a C Program using pointers to read an array of integers and print its elements in reverse order
1:  #include<conio.h>  
2:  #include<stdio.h>  
3:  #include<stdlib.h>  
4:  int main()  
5:  {  
6:        int *ptr,i,n;  
7:        clrscr();  
8:        printf("Enter the no of elements:");  
9:        scanf("%d",&n);  
10:        ptr=(int *)malloc(sizeof(int)*n);  
11:        if(ptr==NULL)  
12:        {  
13:              printf("Not enough memory");  
14:              exit(1);  
15:        }  
16:        for(i=0; i<n; i++)  
17:        {  
18:              printf("Enter %d element : ",i+1);  
19:              scanf("%d",&ptr[i]);  
20:        }  
21:        printf("Array in original order\n");  
22:        for(i=0; i<n; i++)  
23:        {  
24:              printf("%d\n",ptr[i]);  
25:        }  
26:        printf("Array in reverse order\n");  
27:        for(i=n-1; i>=0; i--)  
28:        {  
29:              printf("%d\n",ptr[i]);  
30:        }  
31:        getch();  
32:        return 0;  
33:  }  

Write a C program declare following structure member: name, code, age, weight and height. Read all members of the structure for 100 persons and find list of persons with all related data whose weight > 50 and height > 40 and print the same with suitable format and title

Write a C program declare following structure member: name, code, age, weight and height. Read all members of the structure for 100 persons and find list of persons with all related data whose weight > 50 and height > 40 and print the same with suitable format and title
1:  #include<stdio.h>  
2:  #include<conio.h>  
3:  #define size 3  
4:  struct  
5:  {  
6:        char nm[20],cd;  
7:        int height,age,weight;  
8:  }s[size];  
9:  int main()  
10:  {  
11:        int i;  
12:        clrscr();  
13:        for(i=0;i<size;i++)  
14:        {  
15:              printf("For person %d\n",i+1);  
16:              printf("Enter the name : ");  
17:              fflush(stdin);  
18:              gets(s[i].nm);  
19:              printf("Enter the code : ");  
20:              flushall(.);  
21:              s[i].cd=getc(stdin);  
22:              printf("Enter the age : ");  
23:              fflush(stdin);  
24:              scanf("%d",&s[i].age);  
25:              printf("Enter the weight : ");  
26:              fflush(stdin);  
27:              scanf("%d",&s[i].weight);  
28:              printf("Enter the height : ");  
29:              fflush(stdin);  
30:              scanf("%d",&s[i].height);  
31:        }  
32:        printf("\n\nData having weight>50 & height>40\n");  
33:        printf("\nName   Code Age Height Weight\n");  
34:        printf("--------------------------------\n");  
35:        for(i=0;i<size;i++)  
36:        {  
37:              if(s[i].weight>50 && s[i].height>40)  
38:              printf("%-10s%-5c%3d%7d%7d\n",  
39:  s[i].nm,s[i].cd,s[i].age,s[i].height,s[i].weight);  
40:        }  
41:        getch();  
42:        return 0;  
43:  }  

Define a structure called cricket that will describe the following information: Player name Team name Batting average Using cricket, declare an array player with 50 elements and wire a program to read the information about all the 50 players and print a list

Define a structure called cricket that will describe the following information: Player name Team name Batting average Using cricket, declare an array player with 50 elements and wire a program to read the information about all the 50 players and print a list
1:  #include<stdio.h>  
2:  #include<conio.h>  
3:  #include<string.h>  
4:  struct cricket  
5:  {  
6:        char nm[20],team[20];  
7:        int avg;  
8:  };  
9:  #define total 5  
10:  int main()  
11:  {  
12:        struct cricket player[total],temp;  
13:        int i,j;  
14:        clrscr();  
15:        for(i=0;i<total;i++)  
16:        {  
17:              printf("For player %d\n",i+1);  
18:              printf("Enter the name of player : ");  
19:              fflush(stdin);  
20:              gets(player[i].nm);  
21:              printf("Enter the team : ");  
22:              fflush(stdin);  
23:              gets(player[i].team);  
24:              printf("Enter the batting average : ");  
25:              fflush(stdin);  
26:              scanf("%d",&player[i].avg);  
27:        }  
28:        printf("\nTeam    Name    Average\n");  
29:        printf("               \n");  
30:        for(i=0;i<total;i++)  
31:        {  
32:              printf("%-10s %-10s %7d\n",player[i].team,player[i].nm,player[i].avg);  
33:        }  
34:        getch();  
35:        return 0;  
36:  }  

Write a C Program that search an item from array of string

Write a C Program that search an item from array of string
1:  #include<stdio.h>  
2:  #include<conio.h>  
3:  #include<string.h>  
4:  int string(char[],char[]);  
5:  int main()  
6:  {  
7:        char str[100],find[20];  
8:        int i;  
9:        clrscr();  
10:        printf("Enter the string :");  
11:        gets(str);  
12:        printf("Enter the srting that you want to find : ");  
13:        gets(find);  
14:        i=string(str,find);  
15:        if(i==1)  
16:              printf("%s is found in %s",find,str);  
17:        else  
18:              printf("%s is not found in %s",find,str);  
19:        getch();  
20:        return 0;  
21:  }  
22:  int string(char str[20], char find[20])  
23:  {  
24:        int i,j,flag;  
25:        for(i=0;str[i];i++)  
26:        {  
27:              if(str[i]==find[0])  
28:              {  
29:                    flag=1;  
30:                    for(j=1;find[j];j++)  
31:                    {  
32:                          if(str[i+j]!=find[j])  
33:                          {  
34:                                flag=0;  
35:                                break;  
36:                          }  
37:                    }  
38:                    if(flag==1)  
39:                          break;  
40:              }  
41:        }  
42:        return flag;  
43:  }  

Thursday, 27 August 2015

Write a C Program To Write function to upper the string

Write a C Program To Write function to Reverse the string
1:  #include<stdio.h>  
2:  #include<conio.h>  
3:  void reverse(char[]);  
4:  int main()  
5:  {  
6:        char str[20];  
7:        clrscr();  
8:        printf("Enter string : ");  
9:        gets(str);  
10:        reverse(str);  
11:        getch();  
12:        return 0;  
13:  }  
14:  void reverse(char str[20])  
15:  {  
16:        int i;  
17:        printf("%s in reverse order is ",str);  
18:        for(i=strlen(str)-1;i>=0;i--)  
19:              printf("%c",str[i]);  
20:  }  

Write a C Program To Write function that will scan a character string passed as an argument and convert all lower-case character into their upper-case equivalent

Write a C Program To Write function that will scan a character string passed as an argument and convert all lower-case character into their upper-case equivalent
1:  #include<stdio.h>  
2:  #include<conio.h>  
3:  void upper(char[]);  
4:  int main()  
5:  {  
6:        char str[20];  
7:        clrscr();  
8:        printf("Enter string : ");  
9:        gets(str);  
10:        upper(str);  
11:        getch();  
12:        return 0;  
13:  }  
14:  void upper(char str[20])  
15:  {  
16:        int i;  
17:        printf("%s in upper case is ",str);  
18:        for(i=0;str[i];i++)  
19:        {  
20:              if(str[i]>96 && str[i]<123)  
21:                    str[i]-=32;  
22:        }  
23:        printf("%s",str);  
24:  }  

Write a C Program To Write function which returns 1 if the given number is palindrome otherwise returns 0

Write a C Program To Write function which returns 1 if the given number is palindrome otherwise returns 0
1:  #include<stdio.h>  
2:  #include<conio.h>  
3:  int pelindrome(int);  
4:  int main()  
5:  {  
6:        int n,p;  
7:        clrscr();  
8:        printf("Enter a number : ");  
9:        scanf("%d",&n);  
10:        p=pelindrome(n);  
11:        if(p==1)  
12:              printf("%d is pelindrome",n);  
13:        else  
14:              printf("%d is not pelindrome",n);  
15:        getch();  
16:        return 0;  
17:  }  
18:  int pelindrome(int n)  
19:  {  
20:        char a[6],b[6];  
21:        itoa(n,a,10);  
22:        strcpy(b,a);  
23:        strrev(b);  
24:        if(strcmp(a,b)==0)  
25:              return 1;  
26:        else  
27:              return 0;  
28:  }  

Write a C Program to add first n numbers.

Write a C Program to add first n numbers.
1:  #include<stdio.h>  
2:  #include<conio.h>  
3:  void sum(int);  
4:  int main()  
5:  {  
6:        int n;  
7:        clrscr();  
8:        printf("Enter a number : ");  
9:        scanf("%d",&n);  
10:        sum(n);  
11:        getch();  
12:        return 0;  
13:  }  
14:  void sum(int n)  
15:  {  
16:        int i,s=0;  
17:        for(i=1;i<=n;i++)  
18:        {  
19:              s+=i;  
20:        }  
21:        printf("Sum of first %d integer is %d\n",n,s);  
22:  }  

Write a C Program To Write function prime that returns 1 if its argument is a prime no. and returns 0 otherwise (PRIME NUMBER)

Write a C Program To Write function prime that returns 1 if its argument is a prime no. and returns 0 otherwise (PRIME NUMBER)
1:  #include<stdio.h>  
2:  #include<conio.h>  
3:  int prime(int);  
4:  int main()  
5:  {  
6:        int n,p;  
7:        clrscr();  
8:        printf("Enter a number : ");  
9:        scanf("%d",&n);  
10:        p=prime(n);  
11:        if(p==1)  
12:              printf("%d is prime\n",n);  
13:        else  
14:              printf("%d is not prime\n",n);  
15:        getch();  
16:        return 0;  
17:  }  
18:  int prime(int n)  
19:  {  
20:        int i;  
21:        for(i=2;i<n;i++)  
22:        {  
23:              if(n%i==0)  
24:                    return 0;  
25:        }  
26:        return 1;  
27:  }  

Write a C Program To Use recursive calls to evaluate f(x) = x – x3/3! + x5/5! – x7/7! + ……

Write a C Program To Use recursive calls to evaluate f(x) = x – x3/3! + x5/5! – x7/7! + ……
1:  #include<stdio.h>  
2:  #include<conio.h>  
3:  int main()  
4:  {  
5:        float series(float,int),x;  
6:        int n;  
7:        clrscr();  
8:        printf("\nEnter X:");  
9:        scanf("%f",&x);  
10:        printf("\nEnter n:");  
11:        scanf("%d",&n);  
12:        printf("\nAns %f",series(x,n));  
13:        getch();  
14:        return 0;  
15:  }  
16:  float series(float x,int n)  
17:  {  
18:        long factorial(int);  
19:        float power(float,int);  
20:        float sum=0;  
21:        int i,s=1;  
22:        for(i=1;i<=n;i+=2)  
23:        {  
24:              sum+=(power(x,i)/factorial(i))*s;  
25:              s*=-1;  
26:        }  
27:        return sum;  
28:  }  
29:  float power(float x, int y)  
30:  {  
31:        float p=1;  
32:        int i;  
33:        for(i=1;i<=y;i++)p*=x;  
34:        return p;  
35:  }  
36:  long factorial(int p)  
37:  {  
38:        long f=1;  
39:        int i;  
40:        for(i=1;i<=p;i++)f*=i;  
41:        return f;  
42:  }  

Write a C Program that finds a given word in a string.

Write a C Program that finds a given word in a string.
1:  #include<stdio.h>  
2:  #include<conio.h>  
3:  int main()  
4:  {  
5:        char str[100],find[100];  
6:        int i,j,flag;  
7:        clrscr();  
8:        printf("Enter the string :");  
9:        gets(str);  
10:        printf("Enter the srting that you want to find : ");  
11:        gets(find);  
12:        for(i=0;str[i];i++)  
13:        {  
14:              if(str[i]==find[0])  
15:              {  
16:                    flag=1;  
17:                    for(j=1;find[j];j++)  
18:                    {  
19:                          if(str[i+j]!=find[j])  
20:                          {  
21:                                flag=0;  
22:                                break;  
23:                          }  
24:                    }  
25:                    if(flag==1)  
26:                          break;  
27:              }  
28:        }  
29:        if(flag==1)  
30:              printf("%s is found in %s at %d position",find,str,i+1);  
31:        else  
32:              printf("%s is not found in %s",find,str);  
33:        getch();  
34:        return 0;  
35:  }  

Wednesday, 26 August 2015

Write a C Program that appends the one string to another string

Write a C Program that appends the one string to another string
1:  #include<stdio.h>  
2:  #include<conio.h>  
3:  #include<string.h>  
4:  int main()  
5:  {  
6:        char str[100],app[20];  
7:        clrscr();  
8:        printf("Enter the string :");  
9:        gets(str);  
10:        printf("Enter the srting that you want to append : ");  
11:        gets(app);  
12:        printf("The string is : %s\n",str);  
13:        printf("The string you want to append is : %s\n",app);  
14:        printf("The string after append is : %s\n",strcat(str,app));  
15:        getch();  
16:        return 0;  
17:  }  

Write a C Program that will read a string and rewrite it in the alphabetical order. i.e. the word STRING should be written as GINRST

Write a C Program that will read a string and rewrite it in the alphabetical order. i.e. the word STRING should be written as GINRST
1:  #include<stdio.h>  
2:  #include<conio.h>  
3:  int main()  
4:  {  
5:        char str[100],temp;  
6:        int i,j;  
7:        clrscr();  
8:        printf("Enter the string :");  
9:        gets(str);  
10:        printf("%s in ascending order is -> ",str);  
11:        for(i=0;str[i];i++)  
12:        {  
13:              for(j=i+1;str[j];j++)  
14:              {  
15:                    if(str[j]<str[i])  
16:                    {  
17:                          temp=str[j];  
18:                          str[j]=str[i];  
19:                          str[i]=temp;  
20:                    }  
21:              }  
22:        }  
23:        printf("%s\n",str);  
24:        getch();  
25:        return 0;  
26:  }  

Write a C Program To FInd that will read a text and count all occurrences of a particular word.

Write a C Program To FInd that will read a text and count all occurrences of a particular word.
1:  #include<stdio.h>  
2:  #include<conio.h>  
3:  int main()  
4:  {  
5:        char str[100],find[100];  
6:        int i,j,cnt=0,flag;  
7:        clrscr();  
8:        printf("Enter the string :");  
9:        gets(str);  
10:        printf("Enter the srting that you want to find : ");  
11:        gets(find);  
12:        for(i=0;str[i];i++)  
13:        {  
14:              flag=0;  
15:              if(str[i]==find[0])  
16:              {  
17:                    flag=1;  
18:                    for(j=1;find[j];j++)  
19:                    {  
20:                          if(str[i+j]!=find[j])  
21:                          {  
22:                                flag=0;  
23:                                break;  
24:                          }  
25:                    }  
26:                    if(flag==1)  
27:                          cnt++;  
28:              }  
29:              else  
30:              {  
31:              }  
32:        }  
33:        printf("%s occurs in %s %d times\n",find,str,cnt);  
34:        getch();  
35:        return 0;  
36:  }  

Write a C Program To Find Size of Int , Float And Double Variable

Write a C Program To Find Size of Int , Float And Double Variable
1:  #include<stdio.h>  
2:  #include<conio.h>  
3:  int main()  
4:  {  
5:        clrscr();  
6:        printf("Size of int is -> %d\n",sizeof(int));  
7:        printf("Size of long is -> %d\n",sizeof(float));  
8:        printf("Size of double is -> %d\n",sizeof(double));  
9:        getch();  
10:        return 0;  
11:  }  

Write a C Program to Find String Length

Write a C Program to Find String Length
1:  #include<stdio.h>  
2:  #include<conio.h>  
3:  int main()  
4:  {  
5:        char str[100];  
6:        int l;  
7:        clrscr();  
8:        printf("Enter the string:");  
9:        gets(str);  
10:        for(l=0; str[l]; l++);  
11:        printf("The length of %s is -> %d",str,l);  
12:        getch();  
13:        return 0;  
14:  }  

Monday, 24 August 2015

Write A C Program to Print Floyd's Triangle

#include<stdio.h>
#include<conio.h>

int main()
{
            int i,j,n,k;
            clrscr();

            printf("\n\n Enter  the number : ");
            scanf("%d",&n);

            for(i=1,k=1;i<=n;i++)
            {
                        for(j=1;j<=i;j++,k++)
                        {
                                    printf(" %d ",k);
                        }
                        printf("\n");
            }
            getch();

            return 0;
}


Write a C Program to Print Triangle Patter Program

#include<stdio.h>
#include<conio.h>

int main()
{
            int i,n,j,k;
            clrscr();

            printf("Enter  the number : ");
            scanf("%d",&n);
            printf("\n");
            for(i=0;i<n;i++)
            {
                        for(k=1;k<=i;k++)
                        {
                                    printf(" ");
                        }
                        for(j=1;j<=n-i;j++)
                        {
                                    printf(" %c",96+j);
                        }
                        printf("\n");
            }

            getch();

return 0;
}                                                                                                                    


Write a C Program that accept basic, HRA, and convergence from the user and calculate total salary

#include<stdio.h>
#include<conio.h>

int main()
{
            float basic,HRA,cnvg,totsal;
            clrscr();

            printf("\n Enter basic salary : ");
            scanf("%f",&basic);

            printf("\n Enter HRA : ");
            scanf("%f",&HRA);

            printf("\n Enter convergence : ");
            scanf("%f",&cnvg);

            HRA=(basic*HRA)/100;
            cnvg=(basic*cnvg)/100;
            totsal=basic+HRA+cnvg;

            printf("\n\n Total salary is %.2f",totsal);

            getch();

            return 0;
}


Write a C Program To find the roots of an equation ax2 + bx + c = 0

#include<stdio.h>
#include<conio.h>
#include<math.h>

int main()
{
            float a,b,c,alf,bt,dlt;
            clrscr();

            printf("\n Enter a: ");
            scanf("%f",&a);

            printf("\n Enter b: ");
            scanf("%f",&b);

            printf("\n Enter c: ");
            scanf("%f",&c);

            dlt=b*b-4*a*c;

            if(dlt==0)
            {
                        printf("\n ALPHA=BETA=%f",-b/(2*a));
            }
            else if(dlt<0)
            {
                        printf("\n Imaginary Roots");
            }
            else
            {
                        alf=(-b+sqrt(dlt))/(2*a);
                        bt=(-b-sqrt(dlt))/(2*a);
                        printf("\n\n Alpha = %f\n Beta=%f\n",alf,bt);
            }

            getch();

            return 0;

}

Write a C Program To print all the numbers and sum of all the integers that are greater then 100 and less than 200 and are divisible by 7

#include<stdio.h>
#include<conio.h>

int main()
{
            int i,sum=0;
            clrscr();

            for(i=100;i<200;i++)
            {
                        if(i%7==0)
                        {
                                    printf(" %d ",i);
                                    sum=sum+i;
                        }
            }

            printf("\n\n Sum of all above integers that are divisible by 7 is  %d",sum);

            getch();

            return 0;

}

Write a C Program To Find Factorial Of Inputed Number Using Float

#include<stdio.h>
#include<conio.h>

int main()
{
            int i,n,f=1;
            clrscr();

            printf("\n Enter the Number : ");
            scanf("%d",&n);

            for(i=1;i<=n;i++)
            {
                  f=f*i;
            }

            printf("\n The factorial of %d is : %d",n,f);

            getch();

            return 0;

}

Write a C Program To Print Multiplication Table

#include<stdio.h>
#include<conio.h>

int main()
{
            int i,j,n;
            clrscr();

            printf("Enter the number : ");
            scanf("%d",&n);

            for(i=1;i<=10;i++)
            {
                        printf("\n %d * %d = %d",n,i,i*n);
            }

            getch();

            return 0;

}

Write a C program to Print Fibonacci Series

#include<stdio.h>
#include<conio.h>

int main()
{
            int n1=0,n2=1,n3=1,n,i;
            clrscr();

            printf("Enter the Number : ");
            scanf("%d",&n);

            printf("\n");
            for(i=1;i<=n;i++)
            {
                        printf(" %d ",n3);
                        n3=n1+n2;
                        n1=n2;
                        n2=n3;
            }
            getch();

            return 0;

}

Saturday, 22 August 2015

Write a C Program To Print Series 2,4,16,...n x n by Using Shorthand Operator and While Loop

#include<stdio.h>
#include<conio.h>

int main()
{
            int n,x;  // declare the variable
            long double i=2;  //declare the variable of long double type
            clrscr(); 

            printf("Enter the number : ");
            scanf("%d",&n);

            printf("\n");

            x=1;
            while(x<=n)   //  loop will be execute till the value of x I less or equal n
            {
                        printf("%.2Lf\n",i);  // print the value of I upto 2 decimals only
                        x++;
                        i*=i;
            }

            getch();

            return 0;

}

Write a C Program To Print Series 2,4,6,8,10 Using For Loop

#include<stdio.h>
#include<conio.h>

int main()
{
            int i,n;  // declare two integer type variables
            clrscr();  // clears the output window

            printf("\n Enter the number : ");
            scanf("%d",&n);  // input the value of n

            printf(“\n”);   // will break the line on output window

            for(i=2;i<=n;i++)
            {
                        if(i%2==0)
                        {          
                                    printf(" %d ",i);
                        }
            }

            getch();

            return 0;

}

Write a C Program to Print 1,2...10 Using While Loop

#include<stdio.h>
#include<conio.h>

int main()
{

            int n=1;
            clrscr();

            while(n<=10)  // loop will be executed till n is less or equl to 10
            {
                        printf(" %d ",n);
                        n++;
            }

            getch();

            return 0;

}

Write a C Program To Check Even And Odd Number

#include<stdio.h>
#include<conio.h>

int main()
{
            int n;   // declare integer type variable
            clrscr();

            printf("\n Enter the number : ");
            scanf("%d",&n);

            if(n%2==0)  // check the condition whether the modulo is zero or not
            {
                        printf("\n Entered number %d is EVEN",n);
            }
            else      //   otherwise this part will be executes
            {
                        printf("\n Entered number %d is ODD",n);
            }

            getch();

            return 0;

}

Write a C Program To Check Wheather Inputed Number is Prime Or Not

#include<stdio.h>
#include<conio.h>

int main()
{
            int i,n,flag=0;    // declare variable i, n & flag and initialize flag with 0
            clrscr();

            printf("\n Enter the number : ");
            scanf("%d",&n);

            for(i=2;i<n;i++)
            {
                        if(n%i==0)
                        {
                                    flag=1;
                                    break;
                        }
            }

            if(flag==0)
            {
                        printf("\n %d is a Prime number",n);
            }
            else
            {
                        printf("\n %d ia not a Prime number",n);
            }

            getch();

            return 0;


}

Write a C Program to print year, month and remaining days.



#include<stdio.h>
#include<conio.h>

int main()
{

int day,y,m; /*day for day input & output,
y for calculate year,
m for calculate month
           
printf("Enter the number of days : ");
            scanf("%d",&day);
           
y=day/365;    //calculate years
            day%=365;   // calculate remaining days
           
m=day/30;    // calculate months
            day%=30;    // calculate remaining days
           
printf("%d years,%d months, %d days",y,m,day);
           
getch();
           
return 0;


}

Write a C Program to Convert Rupess into Paisa

#include<stdio.h>
#include<conio.h>

int main()
{
             float rs;  //real variable for rupees
             int ps;    // integer variable for paisa
             clrscr();

             printf("\n\n Enter rupees to convert into paisa : ");
             scanf("%f",&rs);

             ps=rs*100;

             printf("\n Paisa of given rupees is %d",ps);

             getch();

            return 0;

}

Write a C Program to Find Summation , Subtraction And Multiplication of Float Numbers

#include<stdio.h>
#include<conio.h>

int main()
{
 int x,y;   // define 2 integer variable x & y
 float a,b;    // define 2 real variable x & y
 clrscr();    //  clears the output window

 printf("\n Arithmetic operation on integer:-");

printf("\n\n Enter 1st integer number : ");
 scanf("%d",&x);  // input first integer number
           
 printf(" Enter 2nd integer number : ");
 scanf("%d",&y);   // input second integer number
           
 printf("\n\n Addition of two integer numbers is    : %d",x+y);
 printf("\n Multiplication of two integer numbers is : %d",x*y);
 printf("\n Division of two integers numbers is     : %d",x/y);
           
 printf("\n\n Arithmetic operation on float:-");
 printf("\n\n Enter 1st float number : ");
 scanf("%f",&a);   // input first real number
           
 printf(" Enter 2nd float number : ");
 scanf("%f",&b);    // input second real number
           
 printf("\n\n Addition of two float number is :%.2f",a+b);
 printf("\n Multiplication of two float number is :%.2f",a*b);
 printf("\n Division of two float number is:%.2f",a/b);

 getch();

return 0;

}