Skip to main content

Posts

Showing posts from February, 2018

if else statement, sample programs and programs to try

If else statement It is a decision making statement in C programming language which allows the program to test for oneor more condition(boolean value) and execute set of statements depends on the condition.The statement in the if block is executed if the condition is evaluated to be true.If the condition is false the statements in the else block will be executed. Syntax: if  ( condition)  {     statements in if block  } else {  statements in else block }    Note: in C zero and null values are treated as false any other non zero or non null values are true. the else part is optional. example : #include<stdio.h>  int main()  {  int num; printf("Enter a number \n"); scanf("%d",&num); if(num<10)       { printf("The value is less than 10"); }  else       { printf("The value is greater than 10"); }  return 0;  } if else if statement An if statement can be followed by an optional else if...else statement, which is very useful to test va

Programs to try using loops

Loops 1)Print the even numbers between 0 and 50 (use while) 2)Print the odd numbers between 0 and 50 in the reverse order ( use while) 3)Print the series 5,10,15,….,100 (using for loop) 4)Generate the series 1, 2, 4 ,7, 11 ,16....n ( use while...read n) 5)Generate the Fibonacci series 0 1 1 2 3 5 8…..n ( use do while..read n) 6)Find the factorial of a number ( use for statement do not use built in factorial() function) 7)Print the powers of a number upto 10th power. ( Eg: if n=2 then the program should print 2^0, 2^1, 2^2,2^3,…..,2^10 use for loop) 8)Print the multiplication table of a given number. ( use while) 9)Print the numbers from 1 to 10 and their natural logarithms as a table ( use for) 10)Find the sum of the digits of a number.( use while-university question) 11)Check whether the given 3 digit number is an Armstrong number. (use do while Eg:153,370,371,407) ( uq) 12)Find the factors of a number ( use for) 13)Check whether the given number is prime or not ( use

Simple Programs to Begin With

1) area of the circle given the diameter. 2)area of the circle given the circumference. 3)area of the circle given center point (x1,y1) and one point on the perimeter (x2,y2). (Hint: input the two points and compute the distance between them as radius) 4)area of a triangle given three sides a,b,c.( assume they form a triangle) 5)area and perimeter of a right angled triangle given width(w) and height(h). 6)volume and surface area of a sphere given the radius. 7)area of an equilateral triangle given one side (s). 8) volume and surface area of the cylinder given radius(r) and height(h). 9) volume and surface area of a cube given one side ( s). 10)hypotenuse of a right-angled triangle, given the length of the other two sides. Note: assume uniform input values( eg: cm) 11) Find A, the Final Investment Value, using the simple interest formula:  A = P(1 + rt) where P is the Principal amount of money to be invested at an Interest Rate R% per period for t Number of Time Periods. Wher

KTU C programming question paper and evaluation scheme-2015 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 example   in