/*Newly added tags for bing*/ Unipune Codes

Pages

Sunday, 17 October 2021

Even or Odd

 


       
/*
Accept an integer and check whether it is even or odd.
*/

#include<stdio.h>
main()

{
    int n;

    printf("Enter Number- ");
scanf("%d",&n);          if ((n%2)==(0))
    printf("The number is even-\n");     else         printf("The number is even-\n");
}


Wednesday, 5 May 2021

Notes of Different Denomination


       
/*
Cashier has currency notes of denomination 1, 5, 10. Accept the 
amount to be withdrawn from the user and print total number of 
currency notes of each denomination the cashier will have to give
to the user
*/

#include<stdio.h>
main()

{
    int n,t,T,E,O;

    printf("Enter amount- ");
scanf("%d",&n);     T=n/10;     t=n%10;     E=t/5;     O=t%5;

printf("The cashier gives-\n");     printf("%d notes of 10, %d notes of 5 and %d notes of 1.\n",T,E,O);
}


Tuesday, 4 May 2021

Surface area of a room

 

       
/*
Accept l, b, r of a room and l, b of a door and two windows having
same l,b. Print area to be painted and area to be white washed.
*/

#include<stdio.h>
main()

{
    int lr,br,hr,ld,bd,lw,bw;
    float p, w; 

    printf("Enter lr,br,hr,ld,bd,lw,bw- ");
scanf("%d%d%d%d%d%d%d%d",&lr,&br,&hr,&ld,&bd,&lw,&bw);
p=(2*lr*hr)+(2*br*hr)-(ld*bd+2*lw*bw);     w=lr*br;
printf("Area to be painted- %f.\n",p);     printf("Area to be white washed- %f.\n",w);
}


Monday, 3 May 2021

Accept a character and print previous and next character


       
/*
Accept character of a keyboard and print is previous and next
character.
*/

#include<stdio.h>
main()

{
    char ch,ch1,ch2;

    printf("Enter a character- ");
scanf("%c",&ch); ch1= ch-1;     ch2= ch+1;
printf("\nThe previous character is %c.\n",ch1);     printf("The nextcharacter is %c.\n",ch2);
}


Sunday, 2 May 2021

Find Net Salary of an Employee

 


       
/*
The basic salary of an employee is decided at the time of employment. 
Apart from the basic salary; employee gets 10% of basic as have rent
30% basic as D.A. A professional tax as 5% at basic is deducted from 
salary. Accept employee id and basic salary of employee % find net
salary.
*/

#include<stdio.h>
main()

{
    int b;
    float t;

    printf("Enter b- ");
scanf("%d",&b); t=b+(0.1)*b+(0.3)*b-(0.05)*b;
printf(" Net Salary=%f",t); }


Saturday, 1 May 2021

Accept x and y coordinates of two points and find the distance between two points

  


       
/*
Accept x and y coordinates of two points and find the distance
between two points.
*/

#include<stdio.h>
main()

{
    int x1,y1,x2,y2;
    float d;

    printf("Enter x1,y1,x2,y2- ");
scanf("%d%d%d%d",&x1,&y1,&x2,&y2); d=sqrt(((x2-x1)*(x2-x1))+((y2-y1)*(y2-y1)));
printf(" Distance=%f",d); }


Saturday, 24 April 2021

Accept dimensions of a triangle & print area and perimeter of the triangle

 


       
/*
Accept dimensions of a triangle & print area and perimeter of 
the triangle.
*/

#include<stdio.h>
main()

{
    int a,b,c;
    float P,S,A;

    printf("Enter a, b, c - ");
    scanf("%d%d%d",&a,&b,&c);

    P=a+b+c;

    printf("Perimeter = %f",P);
    S=P/2; A=sqrt((S-a)*(S-b)*(S-c));
printf(" Area=%f",A); }


Thursday, 11 February 2021

Accept two numbers and print the arithmetic mean and harmonic mean

 
 
       

#include<stdio.h>

main()

{

    int a,b;

    float A,H;

    printf("Enter a, b: ");

    scanf("%d%d",&a,&b);

    A = (a+b)*0.5;

    printf("Arithmetic Mean = %f\n",A);

    H = ((float)(a*b))/((float)(a+b));

    printf("Harmonic Mean = %f\n",H);

}


Tuesday, 6 October 2020

Accept initial velocity, acceleration and time. Print the Final velocity and Displacement.


 
 
       
/*
Accept initial velocity, acceleration and time. 
Print the Final velocity and Displacement.
*/

#include<stdio.h>
main()

{
    int u,a,t;
    float v,s;

    printf("Enter u, a, t - ");
    scanf("%d%d%d",&u,&a,&t);

    v=u+(a*t);

    printf("Velocity = %f",v);

    s=(u*t)+(0.5*a*t*t);

    printf(" Acceleration=%f",s);
}




Friday, 12 June 2020

Define Class, Create Objects using Parameterized Constructor and Display the Object Count after each Object

 
       

class Student
{
 int roll;
 double per;
 static int cnt=0;
 student () {cnt ++}
 student (int r, String nm, double p)
 {
  roll = r;
  name=nm;
  cnt++;
  System.out.println("Counter= "+cnt);
 }
 public String toString()
 {
  return("Roll no "+roll+" Name= "+name+" Percentage= "+per);
 }
 public static void main(String args[])
 {
  Student s1= new Student (1,"Rohit",65.12);
  System.out.println(s1);
  Student s2= new Student (2,"Pranav",61.12);
  System.out.println(s2);
  Student s1= new Student (1,"Aditya",68.12);
  System.out.println(s1);
  System.out.println("Number of students: "+cnt);
 }
}


Monday, 12 February 2018

Temperature Conversion using C

 
       
/*
Accept the temperature in Fahrenheit and print it in Celsius and kelvin using C.
*/
#include<stdio.h>
main()
{
    int f;
    float c,k;
    printf("Enter f - ");
    scanf("%d",&f);
    c=(f-32)*(0.55555555555);
    printf("Temperature in Celsius = %f\n",c);
    k=c+273;
    printf("Temperature in kelvin = %f\n",k);
}

Sunday, 11 February 2018

Accept the dimensions of a cylinder and print the surface area and the volume using C

/*
Accept the dimensions of a cylinder and print the surface area and the volume using C
*/
#include<stdio.h>
main()
{
    int r,h;
    float sa,v;
    printf("Enter r,h - ");
    scanf("%d%d",&r,&h);
    sa=2*(3.14)*r*(r+h);
    printf("Surface Area = %f",sa);
    v=(3.14)*r*r*h;
    printf(" Volume=%f",v);
}

Tuesday, 23 January 2018

Hello Word


Welcome to the world of coding. This is the very first program you'll face when you step in to the world of coding.
Happy Learning :)

Hello Word using C