Skip to main content

Posts

Showing posts from 2018

WAP to generate the following pattern in C

WAP to generate the following pattern   n=4  4444    i=4  333      i=3  22       i=2  1        i=1  #include<stdio.h> #include<conio.h> main( ) {             int i,j,n;             clrscr();             printf("\nEnter the value of n:");             scanf("%d",&n);             for(i=n;i>=1;i--)             {                         for(j=1;j<=i;j++)      ...

WAP to generate the following pattern using for loop in C

WAP to generate the following pattern   n=4   1  22   333 4444  #include<stdio.h> #include<conio.h> main( ) {             int i,j,n,sp;             clrscr();             printf("\nEnter the value of n:");             scanf("%d",&n);             sp=n-1;             for(i=1;i<=n;i++)             {                         for(j=1;j<=sp;j++)         ...

WAP to read the value of n and generate the following pattern using for loop in C

/* WAP to read the value of n and generate the following  pattern    n=4   1234  123 12 1   #include<stdio.h> #include<conio.h> main() {             int i,j,n;             clrscr();             printf("\nEnter the value of n:");             scanf("%d",&n);             for(i=n;i>=1;i--)             {                         for(j=1;j<=i;j++)                   ...

WAP to read the value of n and generate the following pattern using for loop in C

WAP to read the value of n and generate the following pattern   n=4   1   12   123   1234 */ #include<stdio.h> #include<conio.h> main() {             int i,j,n;             clrscr();             printf("\nEnter the value of n:");             scanf("%d",&n);             for(i=1;i<=n;i++)             {                         for(j=1;j<=i;j++)                ...

WAP to read the value of n and generate the following pattern in c using for loop

WAP to read the value of n and generate the following pattern using for loop in C.   n=4   ****   ***  **   * #include<stdio.h> #include<conio.h> main() {             int i,j,n;             clrscr();             printf("\nEnter the value of n:");             scanf("%d",&n);             for(i=n;i>=1;i--)             {                         for(j=1;j<=i;j++)               ...

WAP to read the value of n and generate the following pattern using for loop in c

WAP to read the value of n and generate the following pattern in C using for for loop.  n=4   *           i=1   **          i=2   ***        i=3   ****      i=4           */ #include<stdio.h> #include<conio.h> main() {             int i,j,n;             clrscr();             printf("\nEnter the value of n:");             scanf("%d",&n);             for(i=1;i<=n;i++)             {           ...

WAP to Find x to power y in C

Write a 'c' program to read the value of x and y and find x to power y ?             e.g.                         x=5      y=3                                     Result = 5^3=5*5*5=125   */   #include<stdio.h>   #include<conio.h>   main( )   {             int x,y,i,result;             clrscr();             printf("\nEnter the value of x and y :");           ...

For loop in C and C++

For loop Structure in C and C++ For Loop : - In for loop first we give the initial value and then.it checks the condition if the condition is true then it enters the loop and execute all the statement inside the curly braces and after this it go to the third part that is increment/ decrement . And it again checks the conditions. In this way it runs till the condition is true. When the condition becomes false it come out of the loop. .   Syntax   for( Initialization ; Condition  ;  Increment/ decrement ) { body of the loop }   EX for(i=0;i<=10;i++) { /**************************/ } c programming language,c programming software,c programming download,c programming online,c programming examples,c programming tutorial,c programming code c programming w3schools,c++ compiler download,turbo c compiler,online c compiler,c compiler for windows,c++ compiler,online compiler online c++ compiler,gdb compiler,c pro...

WAP to read a number and check whether it is Armstrong or not

              Check whether it is Armstrong or not ? Structure num=153        sum=1^3+5^3+3^3=1+125+27=153        Number is Armstrong */ #include<stdio.h> #include<conio.h> main( ) { int num,sum,org; clrscr(); printf("\nEnter the number :"); scanf("%d",&num); sum=0; org=num; do {        sum=sum+(num%10)*(num%10)*(num%10); num=num/10; } while(num!=0); if(sum==org) printf("\nNUmber is Armstrong"); else printf("\nNumber is not Armstrong"); getch(); } c programming language,c programming software,c programming download,c programming online,c programming examples,c programming tutorial,c programming code c programming w3schools,c++ compiler download,turbo c compiler,online c compiler,c compiler for windows,c++ compiler,online compiler online c++ compiler,gdb compiler...

Check whether it is Palindrome or not ?

WAP to read a number and check whether it is P alindrome   or not ? Example num=121  (madam)        rev=121        Number is Palindrome */ #include<stdio.h> #include<conio.h> main( ) { int num,rev,org; clrscr(); printf("\nEnter the number :"); scanf("%d",&num); rev=0; org=num; do { rev=rev*10+num%10; num=num/10; } while(num!=0); if(rev==org) printf("\nNUmber is Palindrome"); else printf("\nNumber is not palindrome"); getch(); } c programming language,c programming software,c programming download,c programming online,c programming examples,c programming tutorial,c programming code c programming w3schools,c++ compiler download,turbo c compiler,online c compiler,c compiler for windows,c++ compiler,online compiler online c++ compiler,gdb compiler,c programming practice questions pdf,c programming practice online,...

Do While Loop Syntax in C

                          Do While Loop Syntax Control Loop Definition With Example HERE Do While :- D o while loop first execute the loop and then it checks the condition if the condition is true it enters the loop next otherwise it come out. So this loop will run at least once. Syntax: Initialization; do { // body of the loop increment/decrement; }  while( condition checking); c programming language,c programming software,c programming download,c programming online,c programming examples,c programming tutorial,c programming code c programming w3schools,c++ compiler download,turbo c compiler,online c compiler,c compiler for windows,c++ compiler,online compiler online c++ compiler,gdb compiler,c programming practice questions pdf,c programming practice online,c programming coding questions and answers pdf,1...

Special Program Using While Loop

              Password Program Using While Loop #include<stdio.h> #include<conio.h> void main() { char ch,s[50]; int i; ch=getch(); i=0;   while(ch!='@') {     s[i]=ch;     printf("*");     ch=getch();         i++; }   s[i]='\0';     printf("\n\nYour Password : %s",s);      getch();  }   c programming language,c programming software,c programming download,c programming online,c programming examples,c programming tutorial,c programming code c programming w3schools,c++ compiler download,turbo c compiler,online c compiler,c compiler for windows,c++ compiler,online compiler online c++ compiler,gdb compiler,c programming practice questions pdf,c programming practice online,c programming coding questions and answers pdf,100 c programming exercises pdf c programming...

Factorial using While Loop in C

                        Find Factorial using while loop in C #include<stdio.h> #include<conio.h> void main() {        int num,fact;        printf("enter the value of num:");        scanf("%d",&num);        fact=1;           while(num>1)              {                 fact=(fact*num);                 num=num-1;              }        printf("%d",fact);        getch(); }        c programming language,c programming software,c programming download,c programming online,c programming examples,c programming tutorial,c programming code c programming w3schools,c++ c...

While loop example 2 in C

          Check password using While loop in C #include<stdio.h> #include<conio.h> void main() {             char ch,s[50];             int i;             ch=getch();             i=0;             while(ch!='@')             {                 s[i]=ch;                 printf("*");                 ch=getch();            ...

Write a 'c' program to find the sum of digits of a number using while loop

                          While loop example Write a 'c' program to find the sum of digits of a number using while loop e.g. num = 456 sum=4+5+6= 15 #include<stdio.h> #include<conio.h> main() { int num,sum; clrscr( ); printf("\nEnter the number :"); scanf("%d",&num); sum=0; while(num!=0) { sum=sum+num%10; num=num/10; } printf("\nSum of digits = %d",sum); getch();              }

Control Loop definition with types

  Control LOOP Loop are two type 1. Entry Control loop: - In which condition is checked at the entry point for the execution of the loop. For and while loop comes in this category 2.Exit control loop : - In which condition is checked at the last point for the execution of the loop. Do while loop is exit control loop. It execute at least once.         1. While Loop : - In while loop we first write the initial  value and                              then we checks the condition                             if the condition is true it enters the loop otherwise it comes out. In true condition it executes all the statement inside the curly braces. And then again checks. The condition this process repeats till the condition is true. Syntax Initialization; ...

Switch case Program with no of cases in C

  Switch case  Program   #include<stdio.h> #include<conio.h> void main() {          int i;          printf("enter the value ");          scanf("%d",&i);                    switch(i) {      case 1:            printf("sunday\n" );      break;    case 2:            printf("moday\n" );     break;     case 3:           printf("tus\n" );    break;    case 4:        printf("web\n" );    break;   default:       printf("No number in case\n"); } getch(); }

Switch case Syntax

              Case Control Statement (Switch case)  Syntax Case Control Statement Switch :- it works on choice which user enters. it remove the problem which created by the else if ladder and save the cup time Syntax:                         Switch(value)                         {                                              Case 1:                         ...

Syntax of else if in C

                        Syntax of else if   else if It remove the above problem but it has own problem it check all the condition until one condition is true. So it is time consuming. Syntax:-                                              If(condition1)                                                 {                          ...

Use of else if to find largest among three in C

            Largest among three using else if   #include<stdio.h> #include<conio.h> void main() { int a,b,c; printf(“Enter three values\n”); scanf(“%d%d%d”,&a,&b,&c); printf(“\n Largest value is “); if(a>b && a>c)    {         printf(“%d\n”,a);    } elseif(b>a && b>c) {       printf(“%d\n”,b);   }                                         else {        printf(“%d\n”,c); } getch();   }

Use else if with example total of marks and percentage & Grade in C

    Use else if with example ( total of marks and percentage & Grade ) "else if" It remove the above problem but it has own problem it check all the condition until one condition is true. So it is time consuming. Syntax:-                                              If(condition1)                                                 {                           ...

Largest of three in C and C++

             Largest of three values using IF else   Largest of three values: #include<stdio.h> #include<conio.h> void main() {                                              float a,b,c;                                              printf(“Enter three values\n”);                               ...