Skip to main content

Posts

Showing posts from September, 2022

PROGRAMMING FOR PROBLEM SOLVING LAB : Program 4

  4.    Write the program for the simple, compound   interest. # include<stdio.h>  #include<math.h>  void main() { int n; float p,q,r,SI=0,CI=0;  clrscr(); printf("\n Enter the value of Principal p = ");  scanf("%f",&p); printf("\n Enter the value of Rate r = ");  scanf("%f",&r); printf("\n Enter the value of Period in year n = ");  scanf("%d",&n); SI = ((p*r*n)/100); printf("\n Simple Interest SI=%f \n",SI);  q = 1+(r/100); CI=p*pow(q,n)-p; printf("\n Compound Interest CI=%f \n",CI);  getch(); } OUTPUT: Enter the value of Principal p = 3500 Enter the value of Rate r = 4 Enter the value of Period in year n = 2 Simple Interest SI=280.000000   Compound Interest CI=285.599731 

PROGRAMMING FOR PROBLEM SOLVING LAB : Program 3

  3.    Write a program for find the max and min from the three   numbers. #include<stdio.h>   void main()   {     int a,b,c;   clrscr();   printf("\n Enter three numbers:\n");   scanf("%d%d%d",&a,&b,&c);   if(a>b && a>c)   printf("\n Maximum number is a = %d",a);   else if(b>a && b>c)   printf("\n Maximum number is b = %d",b);   else   printf("\n Maximum number is c = %d",c);   if(a<b && a<c)   printf("\n Minimum number is a = %d",a);   else if(b<a && b<c)   printf("\n Minimum number is b = %d",b);   else   printf("\n Minimum number is c = %d",c);    getch(); } OUTPUT: Enter three numbers: 54 34 21 Maximum number is a = 54  Minimum number is c = 21

PROGRAMMING FOR PROBLEM SOLVING LAB : Program 2

  2.       Write a simple program that converts one given data type to another using   auto conversion and casting. Take the values form standard   input. #include<stdio.h> void main() { int x = 10,sum=0; // integer x  char y = 'a';  // character Y   float z; double w=1.2;  clrscr(); // y implicitly converted to int. ASCII // value of 'a' is 97 x = x + y; // x is implicitly converted to float z = x + 1.0; printf("\n Integer(implicit:char to Int) Value:x = %d",x); printf("\n Float value(implicit:Int to Float) :z = %f", z); // Explicit conversion from double to int sum = (int)w + 1; printf("\n sum (Exlicit:double to integer)= %d", sum); getch(); } OUTPUT: Integer(implicit:char to Int) Value:x = 107  Float value(implicit:Int to Float) :z = 108.000000  sum (Exlicit:double to integer)= 2

PROGRAMMING FOR PROBLEM SOLVING LAB : Program 1

  1.     Write a simple program that prints the results of all the operators available in C (including pre/ post increment, bitwise and/or/ not, etc.). Read required   operand values from standard   input. # include <stdio.h>     void main() { int a,b,c=0,r=5,result=0;  clrscr(); printf("\n Enter a & b values:\n");  scanf("%d%d",&a,&b); c = a+b; printf("\n ARITHMETIC OPERATORS a+b = %d \n",c);  c = a-b; printf("\n ARITHMETIC OPERATORS a-b = %d \n",c);  c = a*b; printf("\n ARITHMETIC OPERATORS a*b = %d \n",c); c=a/b; printf("\n ARITHMETIC OPERATORS a/b = %d \n",c); c=a%b; printf("\n ARITHMETIC OPERATORS MODULO DIVISION = %d \n",c);  printf("\n PREINCREMENT OPERATOR ++a = %d \n", ++a); printf("\n PREDECREMENT OPERATOR--b = %d \n", --a);  printf("\n POST INCREMENT OPERATOR a++ = %d \n", a++);  printf("\n POST DECREMENT OPERATORa-- = %d \n", a--); b = a; printf(...

PROGRAMMING FOR PROBLEM SOLVING LAB PROGRAMS

  PROGRAMMING FOR PROBLEM SOLVING LAB 1.     Write a simple program that prints the results of all the operators available in C (including pre/ post increment, bitwise and/or/ not, etc.). Read required operand values from standard input. 2.      Write a simple program that converts one given data type to another using auto conversion and casting. Take the values form standard input. 3.    Write a program for find the max and min from the three numbers . 4.    Write the program for the simple, compound interest. 5.   Write program that declares Class awarded for a givenpercentage of marks, where mark <40%= Failed, 40% to <60% = Second class, 60% to <70%=First class, >= 70% = distinction. Read percentage from standard input. 6.   Write a program that prints a multiplication table fora given number and the number of rows in the table. For example, for a number 5 and rows = 3, the output sh...