Skip to main content

Posts

PROGRAMMING FOR PROBLEM SOLVING LAB : Program 7

Write a C program, which takes two integer operands and one operator from   the user, performs the operation and then prints the result. (Consider the   operators  +,-,*, /, % and use Switch Statement) . Algorithm: Step 1: Start Step 2: Read x and y values Step 3: Read option + or – or * or / or %  Step 4: If option is „+‟ res = x + y Step 5: If option is „-‟ res = x - y  Step 6: If option is „*‟ res = x * y  Step 7: If option is „/‟ res = x / y  Step 8: If option is „%‟ res = x % y Step 9: If option does not match with + or – or * or / or % Print select option +, -, *, /, /, % only Step 10: Print x, option, y, res values  Step 11: Stop PROGRAM #include <stdio.h>  #include <stdio.h>  #include <conio.h>  void main() { int a, b, c; char ch;  clrscr() ; printf("\n Enter your operator(+, -, /, *, %):\n");  scanf("%c", &ch); printf("\n Enter the values of a and b:\n");  scanf("%d%d", &a, &b); ...

PROGRAMMING FOR PROBLEM SOLVING LAB : Program 6

  Write a program that prints a multiplication table for a given number and the number of rows in the table. For example, for a number 5 and rows = 3, the output should   be: 5 x 1 = 5 5 x 2 = 10 5 x 3 = 15 …………….. #include <stdio.h>  void main() { int n, j,r=0;  //clrscr(); printf("\n Enter a number:\n ");  scanf("%d",&n); printf("\n Enter number of rows:\n ");  scanf("%d",&r); printf("\n Multiplication table for a given= %d", n);  printf("\n The number of rows in the table=%d", r); for(j=1;j<=r;j++) { printf("\n %d * %d = %d ", n, j, n*j); } //getch(); } OUTPUT: Enter a number:  7  Enter number of rows:  5  Multiplication table for a given= 7  The number of rows in the table=5  7 * 1 = 7   7 * 2 = 14   7 * 3 = 21   7 * 4 = 28   7 * 5 = 35 

PROGRAMMING FOR PROBLEM SOLVING LAB : Program 5

Write program that declares Class awarded for a given percentage of  marks,   where mark <40%= Failed, 40% to <60% = Second class, 60% to <70%=First class,  >= 70% = distinction. Read percentage from standard   input. #include <stdio.h>  void main() { int num; //clrscr(); printf("\n Enter your percentage of marks:\n"); scanf("%d",&num); printf(" \n You entered percentage of marks : %d", num); // printing outputs  if(num >= 70) printf(" \n You got distinction "); // printing outputs  else if (( num >=60)&&(num<70)) printf(" \n You got First Class"); else if ( num >=40 && num<60) printf(" \n You got Second Class");  else if ( num < 40) printf(" \n You Failed in this exam"); //getch(); } OUTPUT: Enter your percentage of marks: 67 You entered percentage of marks : 67   You got First Class

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...

PROGRAMMING FOR PROBLEM SOLVING

PROGRAMMING FOR PROBLEM SOLVING PROGRAMMING FOR PROBLEM SOLVING LAB SYLLABUS Course Objectives: Learning the fundamentals of computers. Understand the various steps in program development. Learning the syntax and semantics of C programming language. Learning the usage of structured programming approach in solving problems. Course Outcomes: The student will learn To write algorithms and to draw flowcharts for solving problems. To convert the algorithms/flowcharts to C programs. To code and test a given logic in C programming language. To decompose a problem into functions and to develop modular reusable code. To use arrays, pointers, strings and structures to write C programs. Searching and sorting problems.   Syllabus Unit - I   Introduction to Programming Introduction to components of a computer system:   disks, primary and secondary memory, processor, operating system, compilers, creating, compiling and executing a program etc., Number systems Introduction to ...

EAMCET and ECET Web Options Guidance For Data Science, AI and Machine Learning.

EAMCET and ECET WEB OPTIONS GUIDANCE   Data Science, AI ,Machine Learning and CSE:  These NEW courses are trending now and according to the research these courses are having  tremendous  future in coming days. All these branches are sub branches of CSE and now it became separate Technologies. For video explanation click on  click here                Branch Name                                                                      Branch code 1. CSE(Artificial Intelligence and Machine Learning)                                            CSM 2. CSE...