Posts

Showing posts from July, 2016

C program to calculate velocity

Image
Write a program in C to enter time and distance so its give velocity. Example:   Input distance: 12 Input time: 6  Output: veocity = 2  Required knowledge: Fundamentals of C, Data types, Taking user input in C  Program: ? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 /**************************************   * C program to calculate velocity. *   **************************************/ #include <stdio.h> void main() {      int d ,t,v;             /*       * get time and distance from user       */      printf ( "Enter distance : \n" );      scanf ( "%d" , &d);      printf ( "Enter time: \n" );      scanf ( "%d" , ...

C program to find square root of a number

Image
Write a C program to input any number from user and find square root of the given number.   Example:  Input number: 4 Output: 2 Required knowledge: Fundamentals of C, Data types, Taking user input in C   Program: ? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 /************************************************   * C program to find square root of a number *   ************************************************/ #include <stdio.h> #include <math.h> void main() {      double num, root;      // Reads the number to find square root      printf ( "Enter any number to find square root: " );      scanf ( "%lf" , &num);      //Calculates square root of num      root = sqrt (num);      printf (...