Posts

Showing posts from January, 2022

Functions

  What is Function ?    In a Program to perform articular task number of times which is having more number of statements, instead of writing those statements number of time we can define a sub routine called Function. The purpose of function is reusability. Function has three parts 1. Function declaration - before the main() 2. Function Calling - within the main() 3. Function Definition - after the main() Functions are following categories 1. Functions with no arguments, no return value 2, Functions with arguments, no return value 3. Function with arguments and return value while giving the function definition we can use as follows    type specifier function_name(arg1,arg2,...)    {       statements;    } In the above type specifier represent what type of value the function is going to return. If the function can't return any value we can represent with void otherwise we can use any related data type. to return the va...

Introduction to Database Oracle

Example Programs for Control Flow Statements

Image
  //Find out sum of two numbers is even or odd main() { int n1,n2,sum; printf("value for n1"); scanf("%d",&n1); printf("value for n2"); scanf("%d",&n2); sum=n1+n2; if(sum%2==0) printf("\n%d is even",sum); else printf("\n %d is odd",sum); } //Accept a character and check whether it is vowel or not main() { char c1; printf("Enter a character"); scanf("%c",&c1); switch(c1) { case 'a': case 'A': case 'e': case 'E': case 'i': case 'I': case 'o': case 'O': case 'u': case 'U': printf("\n%c is vowel",c1);           break; default:printf("\n%c is not vowel",c1);           break; } } // display the numbers between 1 and 10 main() { int n; for(n=1;n<=10;n++) printf("%d ",n); } // display the numbers between 1 and 10 usi...

Control Flow Statements

Control Flow Statements Same Control Flow Statement we can call Programming Constructions. Programming Constructions represent how the program is goin to execute. There are three programming constructions 1. Sequence 2. Selection 3. Iteration 1. Sequence : Without any conditions if the statements are executed then that process is called Sequence. Example : Accept two numbers display sum of those  or interchange 2. Selection: Based on the condition if the execution control is changed from one place to another place then it is called Selection. For this purpose we can use Conditional Statements. 3. Iteration: Executing some set of Statements number of times is called Iteration or Repetition. For this purpose we can use Looping Statements  Conditional Statements : based on the condition execution control is changed from one place to another place for this purpose we can use conditional statements if, switch Syntax-1 if(condition)    statement; else    statemen...

My Channel Trailer

Image

Operators in C

Operators in C The purpose of operators is to perform the manipulations with operands(variables) Operators are following 1 . Relational Operators - For comparing purpose , >,<,>=,<=,==,!= 2.Assignment operator - = 3.Arithmetic Operators - to perform mathematical operations +,-,*,/,% 4.Logical Operators - to compare with multiple conditions or opposition conditions                          &&(and),||(or),!(not) 5.Bitwise Operators - to perform the manipulations with binary data(1s and 0s)    &(bitwise and),|(bitwise or),^(xor),<<(left shift operator),>>(right shift operator ) The following truth table explains how logical operators and xor operator gives the result. Let us take there are two inputs P and Q   P      Q       P&&Q     P||Q     P^Q   0      0      ...

Standard Input/output Functions in C

  Standard input/output functions   1. character based functions             1.getchar()             2.getche()             3.getch()             4.gets(char*)             5.putchar(char)             6.puts(char*)          2. format based function       scanf() - for accept       printf() - for display       1. format specifier       2. address of variable       In case printf there is no fixed number of argument       printf("hello")       int n1=5,n2=10       Sum of 5 and 10 is 15       printf("Sum of %d and %d is %d",n1,n2,n1+n2)      to disy n values the number of argument is n+1