Twitter Facebook Delicious Digg Stumbleupon Favorites More

Wednesday, 2 November 2016

BCA/MCA/BTech - Programs in C - Snippets-3

Programs in C

(in Turbo C)

Snippets-3

Programs in C (in Turbo C) - Snippets-2


Program 13: Write a program in C, which can take an integer number 'num' whose value is 300 and then find the value of (num * num ) / num.

Program taking integer from the user & calculating (num*num)/num



#include <stdio.h>
#include <conio.h>
main()
{
 int num;
 clrscr();
 num = 300;
 printf("\n %d * %d / %d = %d",num,num,num,(num*num)/num);
 getch();
}





Program 14: Write a program in C, which can take an integer number greater than 127 and then print it into character form using %c program taking integer >127 and print equivalent character


#include <stdio.h>
#include <ctype.h>

main()
{
  int num;
  clrscr();

  printf(" Enter the number > 127 : ");
  scanf("%d",&num);
  printf("\n The character equvilant of %d is %c",num,num);
  getch();
}


Program 15: Write a program in C, which can take radius of a circle and then calculate the area of the circle. Using the same radius also calculate the volume of sphere [ take PI = 3.14].
Program takes radius as input & calculates the area.


#include <stdio.h>
#include <conio.h>

main()
{
 float radius,pi;

 clrscr();

 pi=3.14;
 printf("Enter the radius : ");
 scanf("%f",&radius);
 printf("\nThe area of the circle is %f",pi * radius * radius);
 getch();
}



Program 16: Write a program in ‘C’, which can take an integer number num from the user and calculate maths functions  i.e. sin(num), cos(num) and log(num). Program takes an integer number as input  and calculate sin(num),cos(num), log(num)



#include <stdio.h>
#include <math.h>
#include <conio.h>

int main()
{
  float num;

  clrscr();
  printf("Enter the number : ");
  scanf("%f",&num);
  printf("\n\nThe sin(%f) is\t%f",num,sin(num));
  printf("\n\nThe cos(%f) is\t%f",num,cos(num));
  printf("\n\nThe log(%f) is\t%f",num,log(num));
  getch();
  return 0;
}



Program 17: Convert Paisa values (input) into rupees


#include <stdio.h>
#include <conio.h>

main()
{
 int paisa;
 float rupees;
 clrscr(); 
 printf("\nEnter the paisa : ");
 scanf("%d",&paisa);
 rupees = (float)paisa / 100;

 printf("\n%d paisa = %.2f rupees",paisa,rupees);
 getch(); 
}



Program 18: Print Sum of series (say. first 8 terms)


#include <stdio.h>
#include <conio.h>

int main()
{
 float sum;
 clrscr(); 

 sum = 1 + 1/2.0 + 1/3.0 + 1/4.0 + 1/5.0 +1/6.0 + 1/7.0;
 printf("\n1 + 1/2 + 1/3 + 1/4 + 1/5 + 1/6 + 1/7 = %f",sum);
 printf("\n\n....Using Integer Calculation");
 getch(); 
 return 0;
}






Share:

0 comments:

Post a Comment

BCE-Hacks Notes

BCE-Hacks Notes
Chemical Engineering Notes

Maths Resources

Maths Resources
Maths Resources

Buy Books

Buy Books
Buy Books

Geography Quiz

Geography Quiz
Geography Quiz

NodeJS Tutorial

NodeJS Tutorial
Developer-Bytes

History MCQs

History MCQs
History Quiz For Competitive exams

Categories

Popular Posts

GooglePlus

Recent Posts

Unordered List

Express Print Zone

Eduvictors Quizzes

Online Quizzes, Study notes for CBSE Class 6 - 12

Text Widget

Compete4Exams

Study notes for Competitive Exams

Developer Bytes

Developer Bytes
Developer Bytes
Powered by Blogger.

Blogger Tutorials

Blogger Templates

Sample Text

Copyright © IP University Musings BCA, MCA, BBA, MBA, BTech Question Papers and Study Notes | Powered by Blogger
Design by SimpleWpThemes | Blogger Theme by NewBloggerThemes.com