Posts

while loop and their program write a name ten time using while loop in netbeans

Image
Q  write a name ten time using  while loop in netbeans while loop  programming tips  syntax  #include <stdio.h> #include <stdlib.h> /*  *   */ int main(int argc, char** argv) {     int i=1;                                      //  initialive loop variable     while(i<=10)                            //   test the condition      {                                                // execute the loop                                                ...

Create a structure TIME with members hours, minutes and seconds. Write a C program to add two time objects by passing structure variables to function and display result in H: M: S format.

Image
Q .  Create a structure TIME with members hours, minutes and seconds. Write a C program to add two time objects by passing structure variables to function and display result in H: M: S format.                                                                    PROGRAM .   #include <stdio.h> #include <stdlib.h> /*   *   */ struct time {     int hours,minutes,seconds; }; int main(){         struct time t1,t2,temp;     printf("enter the times in hours,minutes,seconds");     scanf("%d%d%d",&t1.hours,&t1.minutes,&t1.seconds);         printf("enter the times in hours,minutes,seconds");     scanf("%d%d%d",&t2.hours,&t2...

Create a structure named company which has name, address, phone and no of Employee as member variables. Read name of company, its address, phone and no of Employee. Finally display these members’ value.

Image
      Q .  Create a structure named company which has name, address, phone and no of Employee as member variables. Read name of company, its address, phone and no of Employee. Finally display these members’ value. ans .                                                  PROGRAM       #include <stdio.h> #include <stdlib.h> struct company {     char name[20],address[50];     int phone,noOfEmployee; }; int main(){         struct company C1;     printf("enter the details of the company");     scanf("%s%s%d%d",C1.name,C1.address,&C1.phone,&C1.noOfEmployee);     printf("Details of the company");     printf("company name=%s \n company address=%s \n co...

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...