Skip to main content

Programs to try using if else


Try the following program using if else
1)Compare two numbers
2)Check whether the given number is even or odd.
3)Find the biggest of 3 numbers
4)Read internal marks( out of 50) and external mark( out of 100) and print passed /failed in internal or external ( use KTU criteria..45%)
5)Check whether the given number is zero, positive or negative.
6)Find the roots of a quadratic equation ( ax^2+bx+c)
7)Read length of 3 sides and check whether it forms a triangle.
8)Check the type of a triangle after reading the three sides ( scalene, isosceles, equilateral)
9) Check the type of a triangle after reading the three vertices ( scalene, isosceles, equilateral)
Note:
From the vertices length of the sides can be computed using the distance formulae.
A scalene triangle is a triangle that has three unequal sides.
An isosceles has two equal sides and two equal angles.
An equilateral triangle is a triangle with all three sides of equal length and also has three equal 60 degree angles.
10) Read  a mark ( out of 100) and print the corresponding grade.
 Percentage Range   Grade
            >=90                            O
            >=85 and <90            A+
>= 80 and <85           A                                
> =70 and <80           B+
> =60 and <70           B
> =50 and <60           C
>=45 and <50            P
<45                              F
11) answer = raw_input("Do you like Python? ")
if  the answer is "yes" print "That is great!" else print "That is disappointing!".

If the user input something else print “Enter yes/no”
12)Check whether a given year is Leap Year or not. A year is leap year if following conditions are satisfied
        1) Year is multiple of 400
        2) Year is multiple of 4 and not multiple of 100.
13)Write a program to check the quadrant of a given point(x,y).
14)Write a program to get the absolute value of number without using the abs() function
15)Write a program that accepts the length of three sides of a triangle as input and determine whether or not the triangle is a right triangle
16)Given three points (x1,y1 ) ,(x2,y2) and (x3,y3), check whether they form a triangle.


Comments

Popular posts from this blog

Files in C

A file is a repository of data that is stored in a permanent storage media, mainly in secondary memory. In order to use the files we should learn how to read information from a file and how to write information into a file. A very important concept in C is the stream.The stream is a common logical interface to the various devices( files).A stream is linked to a file while using an open operation. A stream is disassociated from a file while using a close operation. The current location, also referred to as the current position, is the location in a file where the next fie access will occur.There are two types of streams text and binary. The following are some difference between text and binary files ·Text file is human readable because everything is stored in terms of text. In binary file everything is written in terms of 0 and 1, therefore binary file is not human readable. ·A newline(\n) character is converted into the carriage return-linefeed combination before being written to the d…

KTU C programming question paper and evaluation scheme

APJ ABDUL KALAM TECHNOLOGICAL UNIVERSITY SECOND SEMESTER B.TECH DEGREE EXAMINATION, MAY 2017 CS 100 COMPUTER PROGRAMMING (CS, IT) SCHEME OF EVALUATION
PART A 1 An identifier is a sequence of characters invented by the programmer or to identify or name a specific object. The sequence of characters may be letters, digits, and special character ‘_’known as an underscore Rules: i)Identifiers should start with alphabets. ii)Identifiers are case sensitive iii)A numeric digit should not be the first character iv)Identifier name should not be a keyword v)Identifier may be of any reasonable length 1mark






2mark 2 Associativity defines the direction, left to right or right to left in which operator act upon its operands Unary operators have associativity is from right to left. For examplein the expression &--x, pre decrement works first and then address of operator works Direction + example<

Strings in C

Strings in C Strings are defined as an array of characters. The difference between a character array and a string is the string is terminated with a special character ‘\0’. Declaration of strings: Declaring a string is as simple as declaring a one dimensional array. Below is the basic syntax for declaring a string. charstr_name[size]; In the above syntax str_name is any name given to the string variable and size is used define the length of the string, i.e the number of characters strings will store. Please keep in mind that there is an extra terminating character which is the Null character (‘\0’) used to indicate termination of string which differs strings from normal character arrays. Initializing a String: A string can be initialized in different ways. We will explain this with the help of an example. Below is an example to declare a string with name as str and initialize it with “cek”. 1. charstr[] = "cek"; 2. charstr[50] = "cek"; 3. charstr[] = {'c','…