Posts

Tutorial_07

 ICT/2022/139 R.S.R. Ranathunga 1. Write a program that subtracts the value 15 from 87 and displays the result, together with  an appropriate message, at the terminal. #include <stdio.h> int main () { int a=87; int b=15; int result; result=a-b; printf("subtracts the value 15 from 87 and result is : %i\n", result); return 0; }  2. Identify the syntactic errors in the following program. Then type in and run the corrected  program to ensure you have correctly identified all the mistakes.  #include <stdio.h>  int main (Void)  (  INT sum;  /* COMPUTE RESULT  sum = 25 + 37 – 19  /* DISPLAY RESULTS //  printf ("The answer is %i\n" sum);  return 0;  }  corrected: #include <stdio.h>  int main (void)  {  int sum;  /* COMPUTE RESULT*/   sum = 25 + 37 - 19;  /* DISPLAY RESULTS */  printf ("The answer is %i\n", sum);  return 0;  }...

Tutorial 06

 ICT/2022/139 R.S.R.  Ranathunga 1.       Write a program that prints the following text at the terminal. · In C, lowercase letters are significant. · main is where program execution begins. · Opening and closing braces enclose program statements in a routine. · All program statements must be terminated by a semicolon.   #include <stdio.h>   int main() {         printf("In C, lowercase letters are significant.\n");     printf("main is where program execution begins.\n");     printf("Opening and closing braces enclose program statements in a routine.\n");     printf("All program statements must be terminated by a semicolon.\n");     return 0; } 2.       Print the following shapes. * * * * * * * * * * * * * * * * * * * * * #include <stdio.h>   int main() { ...
Image
ICT/2022/139 R.S.R. Ranathunga   Tutorial 04 & 05(Pseudocode) 1. Generate students repot as shown below.  Index Number Name Mathematics Physics Chemistry Total Average Grade   In this task list, for each student you must input marks of three subjects. Students’ grade is determined according to following criteria:  • Average >= 90%: Grade A  • Average >= 80%: Grade B  • Average >= 70%: Grade C  • Average >= 60%: Grade D  • Average >= 40%: Grade E   • Average < 40%: Grade F  1) What output do you need to generate? Display a student report -Index number, Name, Mathematics  subject marks as M, Physics subject marks as P, Chemistry subject marks as C , Total, Average, Grade  2) What input do you have/ need? Index number, Name, Mathematics subject marks as M, Physics subject marks as P, Chemistry subject marks as C  3) What form will it be in? Index number as String, Name as Text, Mathematics subj...
Image
ICT/2022/139 R.S.R. Ranathunga   Tutorial 03 1) Swap two values stored in two different variables.  1. What output do you need to generate? Display A and B swapped value  2. What input do you have/ need? Input Number 1 as A Input number 2 as B  3. What form will it be in? Integer value of Number 1 Integer value of Number 2  4. Will the program have a list of tasks that needs to be done repeatedly (LOOP)? No  5. What are the other major tasks of the program?  Input A  Input B Declare “C” as Integer  Assign A to C  Assign B to A  Assign C to B  Display A, B 2) Check whether an entered number is negative, positive.  1. What output do you need to generate? Display message status of an entered number  2. What input do you have/ need? A number as x  3. What form will it be in? Numerical value  4. Will the program have a list of tasks that needs to be done repeatedly (LOOP)? No  5. What are the other major tas...
ICT/2022/139 R.S.R. Ranathunga Tutorial 02  1) Swap two values stored in two different variables.  1. What output do you need to generate? Display A and B swapped value  2. What input do you have/ need? Input Number 1 as A Input number 2 as B  3. What form will it be in? Integer value of Number 1 Integer value of Number 2  4. Will the program have a list of tasks that needs to be done repeatedly (LOOP)? No  5. What are the other major tasks of the program?  Input A  Input B Declare “C” as Integer  Assign A to C  Assign B to A  Assign C to B  Display A, B 2  2) Check whether an entered number is negative, positive.  1. What output do you need to generate? Display message status of an entered number  2. What input do you have/ need? A number as x  3. What form will it be in? Numerical value  4. Will the program have a list of tasks that needs to be done repeatedly (LOOP)? No  5. What are the other ma...
ICT/2022/139 R.S.R. Ranathunga   Tutorial 01 1) Print message “Hello World”.  1. What output do you need to generate? A message “Hello World”  2. What input do you have/ need? No  3. What form will it be in? No  4. Will the program have a list of tasks that needs to be done repeatedly (LOOP)? No  5. What are the other major tasks of the program?  Display “Hello World”  2) Print your Curriculum Vitae.  1) What output do you need to generate? Curriculum Vitae  2) What input do you have/ need? Name, Age, Address, Contact number, Educational details  3) What form will it be in? Name as text, Age as integer, Address as string, Contact number as integer, Educational details as string  4) Will the program have a list of tasks that needs to be done repeatedly (LOOP)? No  5) What are the other major tasks of the program?  Create the Curriculum Vitae layout  Input Name  Input Age  Input Address  Inpu...
  C Operators Operators and Operands Operands    Operands are numerical, text and Boolean values that a program can manipulate and use as logical guidelines for making decisions. Operators are used to manipulate and check operand values. If the operator manipulates one operand it is known as unary operator; if the operator manipulates two operands, it is known as binary operator and if the operator manipulates three operands, it is known as ternary operator. C has following operators   Arithmetic operators  all are binary operators  Logical operators  all are binary operators  Relational operators  all are binary operators  Bitwise operators  all are binary operators except ! and ~  Increment, decrement operators  unary operators  Assignment operators  binary operators  Conditional operator  ternary operator  Type cast operator unary operator  sizeof operator  unary operator  Comma operator  binary op...