/*Newly added tags for bing*/ Unipune Codes: 2020

Pages

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);
 }
}