Search This Blog

Saturday, 16 May 2020

programming C(avarage)

two decimal numbers avarage


#include<stdio.h>
int main()
{
    float x,y,z;
    printf("enter the first decimal:\n");
    scanf("%f", &x);
    printf("enter the second decimal:\n");
    scanf("%f", &y);
    z=(x+y)/2;
    printf("avarage is: %.2f", z);
    return 0;
}

   

programming C(add detals and salary)

name,colombo or not,experience year,monthly sale,salesman

#include <stdio.h>



int main()
{



    char Name[10];
    char City;
    int Exp;
    float BaSal,Sales,Add1,Add2,MonRe;



    printf("Enter Your Name : ");
    scanf("%s",&Name);



    printf("Colombo or not (y/n) : ");
    scanf("%s",&City);



    printf("Enter Experience (Number of Years) : ");
    scanf("%d",&Exp);



    printf("Enter Your Basic Salary : ");
    scanf("%f",&BaSal);



    printf("Enter Your Monthly Sales : ");
    scanf("%f",&Sales);





    Add1 = (BaSal * 0.1);
    Add2 = 2500.0;



    if(City=='y'){



        if(Exp>=5){



        if(Sales<25000.0){
        MonRe=(Sales * 0.1)+BaSal +Add1+2500;
        printf("M remuneration of a salesman : %.2f",MonRe);
    }



   else if(Sales>=25000 && Sales<50000){
        MonRe=(Sales * 0.12)+BaSal+Add1+2500;
        printf("Monthly remuneration of a salesman : %.2f",MonRe);
    }



    else{
        MonRe=(Sales * 0.15)+BaSal+Add1+2500;
        printf("Monthly remuneration of a salesman : %.2f",MonRe);
    }
    }else{
        if(Sales<25000.0){
        MonRe=(Sales * 0.1)+BaSal+2500;
        printf("Monthly remuneration of a salesman : %.2f",MonRe);
    }



   else if(25000 <= Sales && 50000 > Sales){
        MonRe=(Sales * 0.12)+BaSal+2500;
        printf("Monthly remuneration of a salesman : %.2f",MonRe);
    }



    else{
        MonRe=(Sales * 0.15)+BaSal+2500;
        printf("Monthly remuneration of a salesman : %.2f",MonRe);
    }}




    }else{



        if(Exp>=5){



        if(Sales<25000.0){
        MonRe=(Sales * 0.1)+BaSal +Add1;
        printf("Monthly remuneration of a salesman : %.2f",MonRe);
    }



    else if(Sales>=25000 && Sales<50000){
        MonRe=(Sales * 0.12)+Sales+Add1;
        printf("Monthly remuneration of a salesman : %.2f",MonRe);
    }



    else{
        MonRe=(Sales * 0.15)+BaSal+Add1;
        printf("Monthly remuneration of a salesman : %.2f",MonRe);
    }
    }else{
        if(Sales<25000.0){
        MonRe=(Sales * 0.1)+BaSal;
        printf("Monthly remuneration of a salesman : %.2f",MonRe);
    }



    else if(25000 <= Sales && 50000 > Sales){
        MonRe=(Sales * 0.12)+BaSal;
        printf("Monthly remuneration of a salesman : %.2f",MonRe);
    }



    else{
        MonRe=(Sales * 0.15)+BaSal;
        printf("Monthly remuneration of a salesman : %.2f",MonRe);
    }
    }



    }
}

     

programming C(%d %d %d %d %d\n",'A','B','C','a','b','c','0','1,/)

%d %d %d %d %d\n",'A','B','C','a','b','c','0','1

#include<stdio.h>
int main()
{
    printf("%d %d %d %d %d %d %d %d %d %d %d %d %d\n",'A','B','C','a','b','c','0','1','2','$','*','+','/');

}
  

programme C(devided or not devided)

 first one devided by second or its not devided properly second(if content)

#include<stdio.h>
int main()
{
    int x,y;
    printf("enter no1\t");
    scanf("%d",&x);
    printf("enter no2\t");
    scanf("%d",&y);

    if (y%x==0){
        printf("first one is devided by second");

    }
    else {
        printf("it is not devided properly from second");
    }
}
     


programme C(radius of circle)

 radius,diameter,circumference,area


#include<stdio.h>
int main()
{
    float radius,diameter,circumference,area;

    printf("enter the radius of the circle: ");
    scanf("%f",&radius);

    diameter=2*radius;
    circumference=2*3.14159*radius;
    area=3.14159*radius*radius;
    printf("The diameter of the circle is %.3f\n",diameter);
    printf("The circumference ofthe circle isd %.3f\n",circumference);
    printf("The area of the circle is %.3f ",area);
    return 0;


}
       

programming c(pass or fail)

pass mark and fail mark (after 50 pass)

#include <stdio.h>
#include <stdlib.h>

int main()
{
    int mark;
    printf("enter your marks");
    scanf("%d",&mark);

    if (mark>50){
        printf("pass");
    }
    else {
        printf("fail");
    }
    return 0;
}

   

                                                                         

programming C(average)

 two numbers average


#include <stdio.h>
#include <stdlib.h>

int main()

{
     int no1,no2;
     printf("Enter first Number: ");
     scanf("%d",&no1);
     printf("Enter second number: ");
     scanf("%d",&no2);
     printf("Sum is %d\n",no1+no2);

     float num1,num2,avg;

     printf("Enter first number: ");
     scanf("%f",&num1);
     printf("Enter second number: ");
     scanf("%f",&num2);

     avg= (float)(num1+num2)/2;

     printf("Average of %f and %f is: %.2f",num1,num2,avg);





    return 0;
}

  

programming C

colour,first numb,second numb,third numb,flot numb,hexadecimal numb,octal numb,unsigned value,perecentage sign


#include <stdio.h>
#include <stdlib.h>

main()
{
    printf("The color: %s\n","blue");
    printf("First number: %d\n",12345);
    printf("Second number: %04d\n",25);
    printf("Third number: %i\n", 1234);
    printf("Float number: %3.2f\n", 3.14159);
    printf("Hexadecimal: %x\n", 255);
    printf("Octal: %o\n", 255);
    printf("Unsigned value: %u\n", 150);
    printf("Just print the percentage sign %%\n",10);

}

  

programme C( find celsius)

 Fahrenheit convert to celsius


#include <stdio.h>
#include <stdlib.h>

int main()
{
   float Cel,Fah;

   printf("Enter Fahrenheit degree \t");
   scanf("%f",&Fah);

   Cel=(Fah-32)*5/9;

   printf("Temperature in Celsius Degrees %f\t",Cel);

   return 0;
}

   

programming C( name and salary)

   salary(if content)


#include <stdio.h>
#include <stdlib.h>

int main()
{
   int basic,new_salary;
   char name[20];

   printf("Please enter your name \n");
   scanf("%s",&name);
   printf("Please enter your basic salary \n");
   scanf("%i",&basic);
   if(basic<5000){
    //5% increment

    new_salary=basic*5/100;
    new_salary=basic + new_salary;

   }
   else if(basic>5000&&basic<10000){
   new_salary=basic*10/100;
   new_salary=basic + new_salary;
   }
   else{
   new_salary=basic*15/100;
   new_salary=basic + new_salary;
   }

   printf("Name :%s\nNew Salary :%i",name,new_salary);
}

      

programme C(adding)

adding two numbers


#include <stdio.h>
#include <stdlib.h>

int main()
{
    double num1;
    double num2;
    printf("Enter First number: ");
    scanf("%lf", &num1);
    printf("Enter Second number: ");
    scanf("%lf", &num2);

    printf("Answer: %.3f", num1 + num2);

    return 0;
}

  


programme C(mark and place)

   merit , pass , faill  (if content)

#include <stdio.h>
int main()
{
    int marks;
    printf("Enter module marks ");
    scanf("%d", &marks);
    if(marks>=75)
    printf("Merit");
    else if(marks>=60)
    printf("Distinction");
    else if(marks>=40)
    printf("Pass");
    else
    printf("Fail");
}

 








programme C(high number)

  at three numbers find high one(if content)

#include <stdio.h>
int main()
{
     int no1,no2,no3,max;
     printf("Enter Three Numbers ");
     scanf("%d %d %d", &no1, &no2, &no3);
     max=no1;
     if(no2>max)
     max=no2;

     if(no3>max)
     max=no3;

     printf("The Highest is %d \n",max);
}

    

programme C(speed=distance/time)

     find average speed

#include <iostream>

using namespace std;

int main()
{
    float distance,time,speed;

    printf("enter distance?\t");
    scanf("%f",&distance);
    printf("enter time?\t");
    scanf("%f",&time);

    speed=distance/time;

    printf("speed is %f",speed);

    return 0;
}
     

programming C(format commands)

   format commands with modifier output

#include <iostream>

using namespace std;

int main()
{
    printf("%6d%6d%6d\n",2,4,6);
    printf("%6d%6d%6d\n",3,9,27);
    printf("%6d%6d%6d\n",4,16,64);
    return 0;
}

       

programming C(data input and output)

age,welcome age and lest be friends

#include <stdio.h>
#include <stdlib.h>

int main()
{

    int age;
    printf("hi how old are you?");
    scanf("%d",&age);

    printf("\n \n");
    printf("welcome %d\n",age);
    printf("lest be friends");
    return 0;
}