Example #include void main() { int a,b,c,n; clrscr(); printf("\nEnter the value of a,b:"); scanf("%d%d",&a,&b); printf("\nMENU"); printf("\n1.ADD\n2.SUB\n3.MULTIPLY\n0.EXIT");

Slides:



Advertisements
Similar presentations
Control Statements. Define the way of flow in which the program statements should take place. Control Statements Implement decisions and repetitions.
Advertisements

Recursion Prog #include <stdio.h> #include<conio.h> main()
Fundamental of C programming
DS:Lab-1 Prepared by: Shipra Shukla Assistant Professor Kaziranga University.
Sort the given string, without using string handling functions.
Understanding Loops Using C Language Week 15 Mr.Omer Salih.
1 ICS103 Programming in C Lecture 10: Functions II.
GE 211 Programming in C Matrix Dr. Ahmed Telba. Example Write function to take coefficients of quadratic equation a, b and c as input parameter and return.
Unit 2 The Switch Case Statements LECTURE – 15
LEVEL-4. NOTE S System Define function #include void main() { int num; float r; clrscr(); printf(“Enter any no\n”); scanf(“%d”,&num); r=sqrt(num); printf(“root.
JAVA PROGRAM Variable, Datatype & Operators. In this page, we will learn about the variable and java data types. Variable is a name of memory location.
Notes Over 5.4 Imaginary Numbers.
5.6 Complex Numbers. Solve the following quadratic: x = 0 Is this quadratic factorable? What does its graph look like? But I thought that you could.
Section 3.2 Beginning on page 104
Introduction to Problem SolvingS1.2.1 Bina © 1998 Liran & Ofir Introduction to Problem Solving Programming in C.
5.4 Complex Numbers Until now, you have always been told that you can’t take the square root of a negative number. If you use imaginary units, you can!
Reading the data from the input devices and displaying the results on the screen are the two main tasks of any program. To perform these tasks user friendly.
SNPL1 GAUSS ELIMINATION & BACK SUBSTITUTION GAUSS ELIMINATION & BACK SUBSTITUTION Dayun Yu Seungmuk Ji.
Topics to be covered  Introduction to array Introduction to array  Types of array Types of array  One dimensional array One dimensional array  Declaration.
PRESENTATION ON SEARCHING SEARCHING Searching is the method to find element from the list of the elements. If element is found then it.
Warm-up. Solving Multi-Step Equations A.1 How do you solve Multi-step equations?
Control Statements (Decision Making)
Properties of Addition and Multiplication. Commutative Property In the sum you can add the numbers in any order. a+b = b+a In the product you can multiply.
UNIT - 4 FUNCTIONS AND POINTERS. FUNCTION Functions is a sub-program that contains one or more statements and it performs some task when called.
CSCI 171 Presentation 5. The while loop Executes a block as long as the condition is true general form: while (condition) { statement 1; statement 2;
FUNCTIONS A function is a set of instructions that can perform a specific task accordingly. A function is a program that performs a specific task according.
Definition of function Types of Function Built-in User Defined Catagories of Function No argument No return value Argument but No return value No argument.
Decision Making It is used to change the order of the program based on condition. Categories: – Sequential structure – Selection structure – Iteration.
INTRODUCTION TO C. C was developed by Dennis Ritchie at Bell laboratory in 1972 It is an upgrade version of languages B and BCPL.
One step equations Add Subtract Multiply Divide  When we solve an equation, our goal is to isolate our variable by using our inverse operations.  What.
FUNCTION Functions is a sub-program that contains one or more statements and it performs some task when called.
Strings program. C Program to Check if a given String is Palindrome #include void main() { char string[25], reverse_string[25] = {'\0'}; int i, length.
Strings program. C Program to Check if a given String is Palindrome #include void main() { char string[25], reverse_string[25] = {'\0'}; int i, length.
For Loop Lecture No 8. Definition In computer science a for loop is a programming language statement which allows code to be repeatedly executed. A for.
Types of Operator Arithmetic operator Relational operator Logical operator Assignment operator Increment or decrement operator(unary) Bitwise operator.
4.4B Factoring Quadratics: Leading Coefficient ≠ 1 : Pattern (ac) Divide out a common monomial if possible. Multiply (a)(c) Use the “X” to find factors.
By Jackson C..  Changing the order of addition or multiplication does not change the sum/product.  Examples :  2 + 3=3 + 2  7 * 9=9 * 7.
$100 $200 $300 $400 $100 $200 $300 $400 $300 $200 $100 Adding multiples of 10 Add 1 to 2 digit numbers with regrouping Add 3 two digit numbers Ways.
Int fact (int n) { If (n == 0) return 1; else return n * fact (n – 1); } 5 void main () { Int Sum; : Sum = fact (5); : } Factorial Program Using Recursion.
 Solve the equation.  1.) 3x = 23  2.) 2(x + 7) 2 = 16 Warm Up.
Recursion It is a process of calling the same function itself again and again until some condition is satisfied. Syntax: func1() { ……….. func1(); }
UNIT II C PROGRAMMING BASICS Problem formulation – Problem Solving - Introduction to ‘ C’ programming –fundamentals – structure of a ‘C’ program – compilation.
UNIT - 3 ARRAYS AND STRINGS. Array An Array is a collection of similar data items, that are stored under a common name. Types –One-Dimensional array –Two-Dimensional.
Program Program is a collection of instructions that will perform some task.
Functions The fruitful & parameterized functions.
CSC COMPUTER EDUCATION, M.K.B.NAGAR CHAPTER 3. CSC COMPUTER EDUCATION, M.K.B.NAGAR Session Objectives Explain If, If..else statements Understand Looping.
MAHENDRAN. Session Objectives Explain Declaration,Initialization of Array Explain Types of Array One Dimensional,Two Dimensional and Multi Dimensional.
UNIT - 5 FUNCTIONS AND POINTERS. FUNCTION Functions is a sub-program that contains one or more statements and it performs some task when called.
The Repetition control structure using while loop.
Programming in C.
Control Structures Introduction
WHILE, DO-WHILE AND FOR LOOPS
FUNCTION Functions is a sub-program that contains one or more statements and it performs some task when called.
THE DISTRIBUTIVE PROPERTY
INTRODUCTION TO C.
LESSON 3 IO, Variables and Operators
ICS103 Programming in C Lecture 10: Functions II
Knowing your math operation terms
Condition Statements.
CHAPTER 7 RECURSIVE FUNCTION
Computer Graphics Matrix
Algebraic Properties.
PROBLEM SOLVING AND OFFICE AUTOMATION
FUNCTIONS AND POINTERS
Recursion Prog #include <stdio.h> #include<conio.h> main()
3.2 Complex Numbers.
ICS103 Programming in C Lecture 10: Functions II
ICS103 Programming in C Lecture 10: Functions II
Presentation transcript:

Example #include void main() { int a,b,c,n; clrscr(); printf("\nEnter the value of a,b:"); scanf("%d%d",&a,&b); printf("\nMENU"); printf("\n1.ADD\n2.SUB\n3.MULTIPLY\n0.EXIT"); printf("\nEnter the choice:"); scanf("%d",&n);

switch(n) { case 1: c=a+b; printf("\nThe result of Addition is:%d",c); break; case 2: c=a-b; printf("\nThe result of Subtraction is:%d",c); break;

case 3: c=a*b; printf("\nThe result of Multiplication is:%d",c); break; case 0: exit(0); break; } getch(); }

Output Enter the value of a,b:5 6 MENU 1.ADD 2.SUB 3.MULTIPLY 0.EXIT Enter the choice:1 The result of Addition is:11

Finding Armstrong No #include void main() { int r=0,sum=0,n,a; printf("\nEnter the number:"); scanf("%d",&n); a=n; while(n>0) { r=n%10; sum=sum+r*r*r; n=n/10; }

if(a==sum) { printf("\nIt is an armstrong number"); } else { printf("\nIt is not an armstrong number"); } getch(); }

Output Enter the number:153 It is an armstrong number

Sum of the Digits #include void main() { int r=0,sum=0,n; printf("\nEnter the no:"); scanf("%d",&n); while(n>0) { r=n%10;

sum=sum+r; n=n/10; } printf("sum of the digits is:%d",sum); }

Output Enter the no:156 sum of the digits is:12

Reverse of a number #include void main() { int r=0,sum=0,n; printf("\nEnter the no:"); scanf("%d",&n); while(n>0)

{ r=n%10; sum=sum*10+r; n=n/10; } printf("Reverse of the number is:%d",sum); getch(); }

Output Enter the no:567 Reverse of the number is:765

Fibonacci Series #include void main() { int f=0,f1=-1,f2=1,n,i; printf("\nEnter the number:"); scanf("%d",&n);

while(f<n) { f=f1+f2; f1=f2; f2=f; printf("\t%d",f); } getch(); }

Output Enter the number:

Swapping #include void main ( ) { int a,b,c; clrscr( ); printf(" \nEnter the value of a:"); scanf("%d",&a); printf(" \nEnter the value of b:"); scanf("%d",&b); c=a; a=b; b=c;

printf(" \nThe value of a is:%d",a); printf(" \nThe value of b is:%d",b); getch( ); } Output: Enter the value of a:5 Enter the value of b:4 The value of a is:4 The value of b is:5

Swapping without using third variable #include void main ( ) { int a,b; clrscr( ); printf(" \nEnter the value of a:"); scanf("%d",&a); printf(" \nEnter the value of b:"); scanf("%d",&b);

a=a+b; b=a-b; a=a-b; printf(" \nThe value of a is:%d",a); printf(" \nThe value of b is:%d",b); getch( ); } Output: Enter the value of a:5 Enter the value of b:6 The value of a is:6 The value of b is:5

Quadratic Equation #include void main ( ) { int a,b,c,d,r1,r2; clrscr( ); printf(" \nEnter the value of a:"); scanf("%d",&a); printf(" \nEnter the value of b:"); scanf("%d",&b); printf(" \nEnter the value of c:"); scanf("%d",&c); d=b*b-4*a*c;

if(d>=0) { r1=(-b+sqrt(d))/(2*a); r2=(-b-sqrt(d))/(2*a); printf(" \nThe roots are %d,%d",r1,r2); } else { printf(" \nThe roots are imaginary"); } getch( ); }

Output Enter the value of a:4 Enter the value of b:5 Enter the value of c:6 The roots are imaginary