Decision making with if statement may be implemented in different forms depending on the complexity of conditions to be tested.The different forms are, Simple if statement if….else statement Nested if….else statement Using else if statement Syntax if( expression ) { if( expression1 ) { statement block1; } else { statement block2; } } else { statement block3; } If the expression is false then block3 will be executed, and if expression is true then again expression1 is evaluated, if it is true then block1 is executed, and if false then block2 will be executed. Example is shown below :: #include<stdio.h>…
-
-
Decision making with if statement may be implemented in different forms depending on the complexity of conditions to be tested.The different forms are, Simple if statement if….else statement Nested if….else statement Using else if statement Syntax if(expression) { //Inside if Statement Are Executed } else { //Inside else Statement Are Executed } //Outside if...else block Statement Are Executed Here, if the expression is true then if block statements are executed and after it directly outside if…else block statements are executed, otherwise else block statements are executed and after it directly outside if…else block statements are executed. It means if expression…
-
Decision making with if statement may be implemented in different forms depending on the complexity of conditions to be tested.The different forms are, Simple if statement if….else statement Nested if….else statement Using else if statement Syntax if(expression) { //Inside Statement Are Executed } //Outside Statement Are Executed Here, If the expression evaluated as true then inside statements are executed, otherwise outside statements are executed. If the if block has only one statement then there is no need to put curly braces {}, but if the if block has more then one statement then it must put curly braces. Example is…
-
puts() function is used to write a line to the output screen. It means puts() function can print entire sentence with white spaces. #include <stdio.h> #include <conio.h> void main() { char string[40]; clrscr(); printf("Enter your full name :: "); gets(string); printf("\n\nYou entered ") puts(string); getch(); } OutPut Enter your full name :: Suvidha Malaviya You entered Suvidha Malaviya It’s Done. Keep It Up Guys…
-
Some of the important point to note :: scanf() and gets() both are used to take input from the user. scanf() can only take input until it encounters a space. The words after space are ignored by it. It means it takes input of only one word. gets() is used to take a single input at a time but can be used to input a complete sentence with spaces unlike scanf(). It means it gets input from user until user hit enter key. gets() takes only a single line at a time. Example is below #include<stdio.h> #include<conio.h> void main() {…
-
Here, we are finding ASCII value of any input character. %c is the format specifier to take character as input. Here, when we use %d instead of %c for character variable then it will print integer ASCII value of character. #include<stdio.h> #include<conio.h> void main() { char character; clrscr(); printf("Enter any character : "); scanf("%c" , &character); printf("\n\nASCII value of %c = %d",character,character); getch(); } OutPut Enter any character : s ASCII value of s = 115
-
Here, printf() is used to display text on the screen. The sign & is used to assign the input value to the variable and store it at that particular location. scanf() is used to take input from the user using format specifier. %d and %i, both are used to take integer numbers as input from the user. %f is the format specifier to take float as input from the user. %c is the format specifier to take character as input from the user. %s is the format specifier to take string as input from the user but %s cannot get string with white space from user,…
-
Basically, the one screen of mobile is knows as Activity in Android. Android Activity Lifecycle is controlled by 7 methods which are included in android.app.Activity class. The android Activity is the subclass of ContextThemeWrapper class. An activity is the single screen in android. It is like window or frame of Java. By the help of activity, you can place all your GUI components or widgets in a single screen. The activity goes from one state to another which is known as activity lifecycle. Methods Of Activity Lifecycle Method Description onCreate called when activity is first created. onStart called when activity…
-
Here, We are performing push and pop operation of stack. #include<stdio.h> #include<conio.h> void push(); void pop(); void main() { int ch,c; clrscr(); do { printf("\n***SELECT OPERATION OF STACK**\n"); printf("\n1.PUSH OPERATION\n2.POP OPERATION\n"); printf("\nEnter you choice::"); scanf("%d",&ch); switch(ch) { case 1: push(); break; case 2: pop(); break; default: printf("\n**INVALID CHOICE**\n"); } printf("\nDOU YOU WANT TO QUIT(0 or 1)::"); scanf("%d",&c); }while(c==0); } void push() { int a[10],n,i,top=-1,no; printf("\n***PUSH OPERATION**\n"); printf("\nEnter the size of array::"); scanf("%d",&n); printf("\n**Enter array elements**\n"); for(i=0;i<n;i++) { scanf("%d",&a[i]); top++; } printf("\nEnter element to insert::"); scanf("%d",&no); if(top>=n) { printf("\n**STACK IS OVERFLOW**\n"); } else { top++; a[top]=no; } printf("\n***AFTER POUSH OPERATION**\n"); for(i=0;i<=top;i++)…
-
Here, gettype() function is used to get the datatype of the variables. Syntax gettype($variable); <?php $a=10; $b=10.98; $c="Hello"; echo "$a is ".gettype($a); echo "<br> $b is ".gettype($b); echo "<br> $c is ".gettype($c); ?> OutPut 10 is integer 10.98 is double Hello is string