Skip to main content

Posts

C Programming #7 (More Complex Repetition)

The for loop: Most of the time only few programmers use while loop as they are too busy using the for loop. The for allows us to specify three thing about a loop in a single line: Setting a loop counter to an initial value. Testing the loop counter to determine whether it's value has reached the number of repetition desired. Increasing the value of loop counter each time the body of the loop has been executed. General for of for statement: for(initialize counter;test counter;increment counter) { do this; and this; and this; } Example program: /*Calculation of simple interest for 3 sets of p, n and r*/ #include<stdio.h> int main() { int p,n,count; float r,si; for(count=1;count<=3;count=count+1) { printf("Enter values of p,n and r"); scanf("%d%d%f,&p,&n,&r"); si=p*n*r/100; printf("Simple Interest=Rs.%f\n",si"); } return 0; } Explanation: When the for statement is exe...

C Programming #6 (Loop Control Instruction)

In C Programming if we want to repeat some statements here we make the use of loops. There are three methods by which we can repeat part of program. Using for statement Using a while statement Using a do-while statement The while loop: It will repeat the program until the condition in while loop become false. Example: /*Calculation of simple interest for 3 sets of p, n and r*/ #include<stdio.h> int main() { int p,n,count; float r,si; count=1; while(count<=3) { printf("\nEnter values of p,n and r"); scanf("%d%d%f",&p,&n,&r); si=p*n*r/100; printf("Simple interest = Rs. %\nf",si); count=count+1; } return 0; } Here this program while loop has the condition to repeat the program 3 times. As in while loop at the end count is increased by 1 every time it execute and when it reaches to 3 control comes out of program and the program terminates. Tips and Traps As I mentioned in m...

C Programming #5 (Complex decision making)

Decision making is very important in C program so to get most out of it similar to boolean maths in C we use logical operators Using if else can be tough while making program with some specific condition So here you can use operators like: if((percentage>=50)&&(percentage<60)) printf("Second division"); Here && in if statement is working as AND operator in this both the condition is to be true so that command in if statement to be execute. So if || is used it is similar to OR operator in this type of statement any one condition is to be true for command to be executed. and ! is NOT operator we will see this one in detail in my further blogs. The conditional operator: The for of conditional operator is like  expression 1? expression 2 : expression 3 It mean if the expression 1 is true then exp 2 will be executed if not then exp 3 will be executed. Example: int x,y; scanf("%d",&x); /*Here I have used scanf to take input f...

C Programming #4 (Decision Control Instruction)

Decision! While writing program when its is executed it execute in the sequence which it is written but in serious programming sequence is according to some condition so here is the need to make decision .Which is implemented in C using : The if statement The if-else statement The conditional operator The if statement: The general form of if statement looks like this: if(this condition is true) execute this statement; Example: #include<stdio.h> int main() { int num; printf("Enter a number less than 10"); scanf("%d",&num); if(num<10) printf("What an obedient servant you are!\n"); return 0; } The if-else statement: In this form when the if statement turn to be false then the else statement is executed Example: /*Calculation of gross salary*/ #include<stdio.h> int main() { float bs,gs,da,hra; printf("Enter basic salary"); scanf("%f",&bs); if(bs<1500) ...

Samsung Galaxy S8 and S8+ (Features)

Samsung has launched a great phone with improvements in all aspects one analyst have termed it as "smartphone innovation super cycle"  Samsung galaxy S8 Samsung galaxy S8+ The only difference in these two phones is it's screen size as you can see in the above picture. Some of the feature to notice about this phones are: Infinity Display : The galaxy S8 has 5.8 inch display crammed into what feels like normal phone with a barely-bezel It has a clean unbranded face, fluid looking display and a mirror like glass back. The only bad thing in display is its bizarre aspect ratio which might result in pillarboxed 16:9 videos. If you still want the actual phablet there is a version with 6.2 display  Force Touch : Samsung is not calling this feature as force touch like Apple but this similar feature is available into the bottom half of it which means if you click on virtual home button it will give you the haptic feedback in response. Thi...

C Programming for Beginner #3 (Instructions)

Types of Instruction Type Declaration: It is used to declare type of variables used in C Program. Arithmetic: It is used to perform Arithmetic operation on constant or variable. Control: It is used to control the sequence of execution. With the help of these instruction we make our C Program. Type Declaration:- Example:  int a float b char code Explanation : int a means we are a can store an integer values in a like 1,2,3,4 etc. float b means we can store a decimal values in b like 1.5 ,2.6 etc. char is used to declare character in C Program. Arithmetic : c=a+b (Addition) c=a/b (Division) c=a*b (Multiplication) c=a%b (Modulus) these gives us the remainder after division. Control : This instruction comes in picture when we deal with the loops,case control sequence of program or decision making. Example Program: include<stdio.h> int main() { int a=5,b=5; c=a+b; d=a-b; e=a/b; f=a*b; g=a%b; printf...

Android O (Android Operating system)

There are many kind of changes and improvements in this new version of Android OS. Increased Ability of the mobile:- aptX bluetooth streaming :-   High quality audio codec is supported for streaming to bluetooth Headsets and Speakers Adaptive icons give devs and OEMs easy shape masks, extra effects :-  "an OEM like Samsung or HTC will provide a unifying mask, which will allow developers to integrate almost any existing app icon into the broader user interface with minimal effort, and no extra graphics work on the icon itself." Neighborhood Aware Networking (NAN) mode for WiFi :-  "You can think about NAN as a combination of WiFi Direct and Nearby. Two hypothetical phones with NAN could find each other and connect without any additional apps or configuration, allowing them to share data at high speeds." Picture-in-picture video for all devices and new windowing features :- "The gist is that when watching video on Android O, you'll be able to shr...