Posts

Showing posts from September, 2019

write a program using do- while loop in netbeans

Image
 Q  write a name  five time using do- while loop what is do - while A do-while loop is comparable to the where as loop except that the condition is usually execute once the body of a loop. it's additionally known as associate exit-controlled loop. The basic format of where as loop is as follows: as we tend to saw in a very  where as loop, the body is execute if and as long as the condition is true. In some cases, we've got to execute a body of the loop a minimum of once even though the condition is false  . this sort of operation  may  be  achieved   by    employing  a   do-while loop. In the do-while loop, the body of a loop is usually execute a minimum of once. once the body is executed , then i...

write a c program using for loop

Image
Q   write a name 5 time  using for loop    HOW T0  WORK FOR LOOP  The  initialization statement is executed only once. Then, the test expression is evaluated.If the check at expression is evaluated to false, the for loop is terminated.  However, if the take a look at expression is evaluated to true, statements within the body of for loop area unit dead, and therefore the update expression is updated. Again the test expression is evaluated.                    This method goes on till the take a look at expression is fake.            When the take a look at expression is fake, the loop terminates.            To learn more about test when the test expression is evaluated to true and false), check out                 relational and logical operators. PROGRAM #include...

Write a c program to check a voting AGE condition using conditional/ternary

Image
Q1 Write a c program to check a voting AGE condition #include <stdio.h> #include <stdlib.h> /*  *  */ int main(int argc, char** argv) {     int a;     printf("ENTER A AGE\n");     scanf("%d",&a);     a>17 ? printf("YOU CAN VOTE"): printf("YOU CAN'T VOTE");         return (EXIT_SUCCESS); } Q2    WRITE A C PROGRAM  TO CHECK WEATHER RESULT #include <stdio.h> #include <stdlib.h> /*  *   */ int main(int argc, char** argv) {     int a;     printf("ENTER A result");     scanf("%d",&a);     a>32 ? printf("pass "): printf("Better luck next time");               return (EXIT_SUCCESS); } Q3 Write a program to check weather a number    is positive or negative #include <stdio.h> #include ...

Write a c program to check a voting AGE condition using if-else

Image
Q1 Write a c program to check a voting AGE condition Given age of someone and that we ought to check whether person is eligible for voting or not. To check that someone is eligible for voting or not, we'd like to examine whether or not person’s age is bigger than or up to eighteen. For this we tend to are reading age in a very variable a and checking the condition a>=18, if the condition is true, "person are eligible for voting" else no. #include <stdio.h> #include <stdlib.h> int main(int argc, char** argv) {         int a;     printf("ENTER A AGE\n");     scanf("%d",&a);     if (a>=18)     {         printf("YOU CAN VOTE");             }     else     {         printf("YOU CAN'T VOTE...

Write a program to check weather a number is positive or not positive using IF

Image
Q1 Write a program to check weather a number   is positive or not positive using if IF  ----If  statement is one of the simplest  decision making control statement. Syntax If (expression) {         Frist   Statement ;        …… ………… ……… …………..        …… ………… …………  ………       Last  statement;   } How to work if statement The if statement evaluates the take a look at expression within the parenthesis (). If test condition  is evaluated to true, statements within the body of if are executed. If test condition  is evaluated to false, statements within the body of if don't  executed If condition  is true Int check =10; If (check < 33) {   //  executed code } // executed code after if If condition  is false Int check =10; ...

C program find to the largest three number using pointer

Image
C program find to the  largest   three number  using pointer   In this program i have three integers n1,n2 or n3 . i assigned the address  of three  to three pointer p1 ,p2 or p3. Now   i  started the comparison on the value stored  at the address pointer.                        Algoritham Start  Read a number to be compare as n1 ,n2 or n3. check if n1 is largest then n2. if condition is true , then check if n1 is largest than n3. if condition is true , then print largest number is n1. if condition is false, then  print largest number is n3.       4. If condition is  false , then check if n2 is largest than n3        a .  If condition is true , then print n2 is largest number .       b.  If condition is false , than print n3 is largest number.       ...

sum of all the elements of an array using pointer IN C program

Image
 C- program to find the sum of all the elements of an array using pointer   This is  a C program to find the answer of sum of  the array elements using pointer  Problem Description  calculate the sum of array elements using pointer.  This c program add the array elements  values uses pointer. problem solution   First create a pointer variable  , which point an int data.   Take a size of array as input.   after create a size of array  * size of all array elements after iterate for loop taking element as input. again use for loop to access the address stored in pointer ,add the iterator value , so as to all access elements of array . source code This source code of the C program  to calculate the sum of array using pointer . this program successfully compilied and tested by netbeans . Program   #include <stdio.h> #include <stdlib.h> int main(int...