Sunday, April 30, 2023

find a point is lie on x axis,y axis or origin or not using c programming .

 //find a point is lie on x axis,y axis or origin or not 

#include "stdio.h"

int main ()

{

int x,y;

printf ("Enter the point : \n");

scanf("%i%i",&x,&y);

if (y==0 && x!=0){

printf ("The point is on x axis \n");

}

else if(x==0 && y!=0){

printf ("The point is on y axis \n");

else if (x==0 && y==0){

printf ("The point is in the origin \n");

}

else{

printf ("the point is not on x or y or origin \n");

}

return 0;

}

       output    output    output    output    otuput

Enter the point :

5

0

The point is on x axis

                                         or

Enter the point :

0

6

The point is on y axis

                                        or 

Enter the point :

0

0

The point is in the origin

                                         or 

 Enter the point :

3

4

the point is not on x or y or origin


find the larger element between area and perimeter of a triangle

 //find the larger element between  area and perimeter of a triangle 

#include "stdio.h"

int main (){

float per,area,lng,brt;   /*lng--->length ;per--->perimeter ; brt--->breadth*/

printf ("Enter the length and breadth of a triangle \n");

scanf ("%f%f",&lng,&brt);

area=lng*brt;

per=2*(lng+brt);

if (area>per){

printf ("The area of triangle is bigger than it's perimeter \n");

}

else {

printf ("The area of triangle is smaller than it's perimeter \n");

}

return 0;

}


            output                 output                  output                output 

Enter the length and breadth of a triangle

4

5

The area of triangle is bigger than it's perimeter

find a triangle exists or not using its three angle

 //find a triangle exists or  not using its three angle 

#include "stdio.h"

int main (){

int a1,a2,a3,total;

printf ("Enter all angle :\n");

scanf ("%i%i%i",&a1,&a2,&a3);

total=a1+a2+a3;

if (total==180){

printf ("the triangle exists \n");

}

else {

printf ("the triangle don't exists ");

}

return 0;

}

               output          otuput                output              output           

Enter all angle :

60

80

40

the triangle exists

THE AGGREGATE (SUM) MARKS AND PERCENTAGE MARKS OF A STUDANTS IN 5 SUBJECTS WITH EACH 100 MARK


//THE AGGREGATE MARKS AND PERCENTAGE MARKS OF A STUDANTS IN 5 SUBJECTS  WITH EACH 100 MARK

#include"stdio.h"
int main ()
{
 
  int sub1,sub2,sub3,sub4,sub5,agg;

  printf ("enter all 5 marks :\n");
  scanf ("%i%i%i%i%i",&sub1,&sub2,&sub3,&sub4,&sub5);
  agg=sub1+sub2+sub3+sub4+sub5;
  printf ("the aggregate of all 5 marks is %i\n ",agg);
  float per= (agg/500.00)*100;
  printf ("percentage is %f",per);
  return 0;
}

OUTPUT OUTPUT OUTPUT OUTPUT
enter all 5 marks : 90 90 90 90 90 the aggregate of all 5 marks is 450 percentage is 90.000000

find the idstance between two buildings in different ways

 //find the idstance between two buildings in different ways 

#include "stdio.h"

int main (){

float km,cm,feet,mtr,ich;

printf ("The distance between two cityies is :\n");

scanf ("%f",&km);

mtr=km*1000; //for meter

printf ("The distance  (in meter ) between two cityies is %f\n ",mtr);

cm=mtr*100; //for cm

printf ("The distance  (in centimeter ) between two cityies is %f\n ",cm);

ich=cm/2.54;  //in inch

printf ("The distance  (in inch) between two cityies is %f\n ",ich);

feet=ich/12;  //in feet 

printf ("The distance  (in feet ) between two cityies is %f\n ",feet);

return 0;

}

        output              output                      output      


The distance between two cityies is :

1

The distance  (in meter ) between two cityies is 1000.000000

 The distance  (in centimeter ) between two cityies is 100000.000000

 The distance  (in inch) between two cityies is 39370.078125

 The distance  (in feet ) between two cityies is 3280.839844

Saturday, April 29, 2023

find the area of a triangle

 //find the area  of a triangle 

#include "stdio.h"

#include "math.h"

int main ()

{

  float a,b,c,s,area;

printf("Enter the sides of triangle :\n");

scanf ("%f%f%f",&a,&b,&c);

s=(float)(a+b+c)/2;

area=sqrt(s*(s-a)*(s-b)*(s-c));

printf ("The ara of a triangle is %lf\n",area);

return 0;

}

               output                  output     

 Enter the sides of triangle :

3

4

5

The ara of a triangle is 6.000000              

Find a year is leap year or not .

 //find a year is leap  year or not 

#include "stdio.h"

int main ()

{

int yr;

printf ("Enter the year:\n");

scanf ("%i",&yr);

if (yr>=1000 && yr%4==0)

{

printf (" %d is a leap year \n",yr);

}

 

else if (yr>=1000 && yr%4!=0)

{

printf ("%i is not a leap year \n",yr);

}

else if (yr<1000)

{

printf ("Enter a vaid year that is greter than 1000\n");

}

return 0;

}

     

          output             output                    output 

Enter the year:

2023

2023 is not a leap year

                                                           or 

Enter the year:

2024

 2024 is a leap year

                                                     or 

Enter the year:

999

Enter a vaid year that is greter than 1000

Calaulation of Profit and loss of a seller in a marcket .

 //find a seller is able to profit or not 

#include "stdio.h"

int main (){

int ap,sp,pft,lss;    /*ap=actual price ;sp=selling price ;pft=profit  ;lss=loss;*/

printf ("Enter the actual price and selling price of an item :\n");

scanf ("%i%i",&ap,&sp);

    if(sp>ap)

{

pft=sp-ap;

printf ("the profit is :%d\n",pft);

}

else if (ap>sp){

lss=ap-sp;

printf ("the loss is %d\n",lss);

}

else {

printf ("no profit no loss");   // as ap=sp

}

return 0;

}


                output output output output

Enter the actual price and selling price of an item :

23

34

the profit is :11

                                or 

Enter the actual price and selling price of an item :
54
52
the loss is 2

                                 or 

Enter the actual price and selling price of an item :
34
34
no profit no loss.

Monday, April 24, 2023

add two arrey

 /*add two arrey with rowwise */

#include"stdio.h"

int main (){

int i;

int arr1[5]={12,13,14,15,16};

int arr2[5]={21,31,41,51,61};

int arr3[5];

for (i=0;i<5;i++){

arr3[i]=arr1[i]+arr2[i];

printf ("%d\n",arr3[i]);

}

return 0;

}

                 output                     output                outpu
33
44
55
66
77

Wednesday, April 19, 2023

create a multiplication table of any number

  /*create a multiplication table of  any number  */


#include "stdio.h"
int main (){
int num,i,mul;//mul---> multiplication
printf ("enter any integer number :");
scanf ("%i",&num);
printf ("the multiplication table is: \n");
for (i=1;i<=10 ;i++){
    mul=num*i;//mul---> multiplication
    printf ("  %i*%i=%i \n",num,i,mul);
}
return 0;
}

output output output output
9*1=9 9*2=18 9*3=27 9*4=36 9*5=45 9*6=54 9*7=63 9*8=72 9*9=81 9*10=90

create a simple calculator using c programming

  /*create a simple calculator using c programming */

 #include"stdio.h"
 int main (){
double num1,num2,result;
char operator;
printf ("enter two numbers and  type of operator : ");
scanf ("%lf %lf %c",&num1,&num2,&operator );
switch (operator ){
   case '+':
result=num1+num2;
printf ("the result is %lf",result);
break;
   case '-':
result=num1-num2;
printf ("the result is %lf",result);
break;
   case '*':
result=num1*num2;
printf ("the result is %lf",result);
break;
   case '/':
result=num1/num2;
printf ("the result is %lf",result);
break;
default:
printf ("invailed operator ");
}
return 0;
 }

output output output output

enter two numbers and type of operator : 40 20 * the result is 800.000000

Sunday, April 9, 2023

C Program to Print Even and Odd Numbers in an Array

 //C Program to Print Even and Odd Numbers in an Array

#include "stdio.h"

int main (){

int arr[200],i,n;

printf ("enter the size of arrey :");

scanf ("%i",&n);

printf ("enter all %d elements in the arrey :",n);

for (i=0;i<n;i++){

scanf ("%i",&arr[i]);

}

printf ("all even elements in the arrey are :\n");

for (i=0;i<n;i++){

if (arr[i]%2==0)

printf ("%i\n",arr[i]);

}

printf ("\nall odd elements in the arrey are :\n");

for (i=0;i<n;i++){

if (arr[i]%2!=0)

printf ("%i\n ",arr[i]);

}

return 0;

}

                      output       output          output              output             output     

enter the size of arrey :6

enter all 6 elements in the arrey :34

54

56

78

77

23

all even elements in the arrey are :

34

54

56

78


all odd elements in the arrey are :

77

 23   

find the sum of all arrey elements

 /*********** find the sum of all arrey elements *********/

#include "stdio.h"

int main (){

int i,sum=0,marks[1000],size;

printf ("enter the size of the arrey :");

scanf ("%i",&size);

printf ("enter all %d elements in the arrey :",size);

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

scanf ("%i",&marks[i]);

sum=sum+marks[i];

}

printf("the sum of the marks  is %d :",sum);

return 0;

}

                     output            output               output                 output           outptut

enter the size of the arrey :6

enter all 6 elements in the arrey :5

6

7

2

5

5

the sum of the marks  is 30 

find a number is exists or not in an arrey

 //find a number is exists or not in an arrey 

#include "stdio.h"

int main (){

int arr[2000],i,n,elements;

printf ("enter the size of arrey : ");

scanf ("%i",&n);

printf ("enter all %d elements in the arrey :",n);

for (i=0;i<n;i++){

scanf ("%i",&arr[i]);

}

printf("enter the elements that you want to find within an arrey :\n");

scanf ("%i",&elements);

for (i=0;i<n;i++){

if (elements==arr[i]){

printf ("I find %d at the position %i\n",elements,i+1);

return 0;

}

}

printf ("the %d elements not found in the arrey \n ",elements );

return 0;

}

                                output              output               output            output 

enter the size of arrey : 6

enter all 6 elements in the arrey :67

76

78

87

98

89

enter the elements that you want to find within an arrey :

98

I find 98 at the position 5


Saturday, April 8, 2023

find the maximum and minimum number within an arrey

 //find the maximum and minimum number within an arrey 

 #include "stdio.h"

 #include "conio.h"

 

 int main (){

    int max,min,i,arr[2000],n;

    printf ("enter the size of the arrey :");

    scanf ("%i",&n);

    printf ("enter all %d numbers :\t\n",n );

    for (i=0;i<n;i++){

        scanf ("%i",&arr[i]);

    }

    min=max=arr[0]; //assume that all are same 

    for (i=0;i<n;i++){

        if (min>arr[i]){

            min=arr[i];

        }

        if (max <arr[i]){

            max=arr[i];

        }

    }

      printf ("minimum number of the arrey is : %i\n",min);

          printf ("maximum number of the arrey is : %i",max); 

         return 0;

 }

                        output               output                       output                        output       

enter the size of the arrey :6

enter all 6 numbers :

34

54

67

98

90

22

minimum number of the arrey is : 22

maximum number of the arrey is : 98

reverse an arrey in c programming

 //reverse an arrey in c programming

#include "stdio.h"
int main (){
    int arr[50];
    int n,i;
    printf ("enter the number of elements  in the arrey :");
    scanf ("%i",&n);
    printf("enter all elements in the arrey: ");
    for (i=0;i<n;i++){
        scanf ("%i",&arr[i]);
    }
    printf ("the arrey with reverse order is like that :");
    for (i=n-1;i>=0;i--){
        printf ("%i\n",arr[i]);
    }
    return 0;

}

output output output output output
enter the number of elements in the arrey :6 enter all elements in the arrey: 78 98 90 89 76 56 the arrey with reverse order is like that :56 76 89 90 98 78

Tuesday, April 4, 2023

create an arrey from take data from user

  //create an arrey from take data from user

 #include "stdio.h"
 int main (){
    int i;
    int marks[9];
printf ("enter all 9 marks  :\n");
for (i=0;i<9;i++){
  scanf ("%i\n",&marks[i]);
}
printf ("display  all 9 marks :\n");
for (i=0;i<9;i++){
    printf ("%i\n",marks[i]);
}
return 0;
   
 }

output output output output
32 34 54 56 76 78 89 76 56 45 display all 9 marks : 32 34 54 56 76 78 89 76 56 45

print all arrey elements

 //print all arrey elements

#include "stdio.h"
int main (){
    int rollno[5]={30,34,45,54,56};
    printf ("%i\n",rollno[0]);
 printf ("%i\n",rollno[1]);
  printf ("%i\n",rollno[2]);
   printf ("%i\n",rollno[3]);
    printf ("%i\n",rollno[4]);
    return 0;
}
output output output

30 34 45 54 56

Monday, April 3, 2023

1st project :: create a digital watch in c using for loop

  //create a digital watch in c using for loop

 #include "stdio.h"
 #include "conio.h"
 #include "stdlib.h"
 int main (){
    int h=0,m=0,s=0;
    double i;
    printf ("enter the time format like HH:MM:SS\n ");
    scanf ("%i%i%i",&h,&m,&s);
    start :;
    for (h;h<24;h++){
        for (m;m<60;m++){
            for (s;s<60;s++){
                system ("cls");
                printf ("\n\n\n\n\n\t\t\t\t\t %d:%d:%d\n",h,m,s);
                for (i=0;i<89999900;i++){
                      i++;
                      i--;
                }
            }
            s=0;
        }
        m=0;
    }
    h=0;
    goto start;
    return 0;
 }

print a multiplication table of any integer taking from user

 // print a multiplication table of any integer taking from user  #include "stdio.h" int main () { int n,mul,i; printf ("...