Thursday, 16 July 2015

Escape Sequence in c language

The Escape Sequence Using For in c Language. Escape sequence Mostly Used in Printf() Operation in c program. We check the operation below also. But,  1st  Learn Why Use Escape Sequence?


Different Type of Outputs Represents in c program.

\n                                          Represents a newline character

\r                                           Represents a carriage return

\b                                          Represents a backspace

\f                                           Represents a from-feed character

\t                                           Represents a horizontal tab

\v                                          Represents a vertical tab

\a                                          Inserts a bell (alert) Character or ( Beep Sound )

\?                                          Inserts a question mark Symbol ( ? )

\"                                           Inserts a Double Quote ( " )

\'                                           Inserts a single Quote ( ' )

\\                                           Inserts a Backslash ( \ )

Trigraph Sequences 

In General Every One Ca Use questions mark directly in string. The \?  escape sequence only exists because there are nine special sequence of characters called Trigraph Sequence. That are Three Characters Sequence for Representing each of the characters #, [, ], \, ^, ~, /, {, }. 

??=         #

??(         [

??)         ]

??/        \

??<        {

??>        }

??'         ^

??!        |

??-        ~

Example : 

Printf(" ??<Welcome Alltechprograms??>");

Output:

{ Welcome Alltechprograms }

logo

Explain C Program Step By Step

The C Program Can Be Explained Using Simple Program. Because, Understand Every One Way Of Learning in C Program & also Explain  comments where do use in c program. 

Program

#include<stdio.h>                                    //  This is a preprocessor directive

int main(void)                                           //  This is identifiers the function main()

{                                                               //  This marks the beginning of main()

printf("Welcome Alltechprograms");        //  This line outputs a quotation 

return 0;                                                   //  This return control to the operating system 

}                                                              //  This marks the end of the main() 


Then above the Symbol  //. Using For C Program Explain time. ( Good Way Understand ). Now , Comments also Be Used Explain Symbols in c program  /* sum text */ .

Comments Using Sample in C Program

#include<stdio.h>   /* This Line is a Preprocessor   directive  */


logo

Wednesday, 15 July 2015

Create C Programs Using Fundamental Stages

Create c Programs Using Fundamental Stages are 4 (Four) Types.

  1. Editing.
  2. Compiling.
  3. Linking.
  4. Executing.
Now , Below Explain The Each Topic

Editing

Editing is the process of creating and modifying C Source code. In Fact, an editor often provides a complete environment for Writing, Managing,Developing and testing your Programs.This is Some Times called as IDE ( Integrated Development Environment ). The Editor Using General Purpose Text Editor To Create Your Source Files.


Compiling

The Compiler converts your Source Code into Machine Language and detects and reports in the compilation process. The input to this stage is the file you produce during your editing, which is usually referred to as a source file.


Linking

The Linker Combines the object modules generated by the compiler from source code files ,adds required code modules from the standard library supplied as part of c, and welds everything into an executable whole. The Linker also detect the errors.

Executing

The Execution stage is where our run the program, having completed all the previous process successfully. But, Some Times  This stage can also generate a wide variety of error conditions. That can include producing the wrong output. We Can Use also Run  windows .exe file for Executing Output Display.

The Above Section is  Explain The Some Instructions For C Program Compile And Execution Statements.

Sample Program

#include<stdio.h>
int main()
{
printf("Welcome Alltechprograms !!");
return 0;
}

logo

Friday, 10 July 2015

armstrong number in c program

Armstrong Numbers in C Program


Armstrong Number :  The Armstrong Numbers is a Number. Such That the Sum ! of it's digits raised to the third power is equal to the number ! itself.

For Example :  Take A Armstrong Number Like 153

1 3  + 53    +33  =  1+ 125 + 27 = 153      //  Here Power of 3 is number of digits in Given number.

Program For Armstrong Number Find in c Program

#include <stdio.h>
 int power(int, int);
 int main()
{
   int n, sum = 0, temp, remainder, digits = 0;
   printf("Enter an integer\n");
   scanf("%d", &n);
   temp = n;
   while (temp != 0) 
{
   digits++;
   temp = temp/10;

}

   temp = n;
   while (temp != 0) {
   remainder = temp%10;
   sum = sum + power(remainder, digits);
   temp = temp/10;
 }

   if (n == sum)
  printf("%d is an Armstrong number.\n", n);
   else
   printf("%d is not an Armstrong number.\n", n);
   return 0;
}

int power(int n, int r) 
{
   int c, p = 1;
   for (c = 1; c <= r; c++) 
   p = p*n;
   return p;   

}

Outputs


armstrong






logo

Addition two Pointers in c Program

 Addition of pointers in c program


Pointer: A pointer can be declare as a ( * ) Symbol. Now Bellow Can Be Addition Of Two Variable Pointers Example Program With Outputs.

Program

#include<stdio.h>
int main()
{
int *a,*b,c,first,second;
printf("enter the two numbers :\n");
scanf("%d%d",&first,&second);
a=&first;
b=&second;
c=*a+*b;
printf("the Sum Of Two Pointers : %d",c);
}

Output

pointers addition
logo

Sunday, 5 July 2015

Loops in c Language

Loops in C Language

Loops : The Computer lies in its ability to perform a set of instructions repeatedly. That Means Loop is Number of Times Repeat Until a Particular Condition is Satisfied. This Repetitive Operation is Done Through a Loop Control Statement. 
loops in c language alltechprograms

There are Three Methods. They are,
  • Using a For Statement 
  • Using a While Statement
  • Using a do-While Statement
First we need to Understanding While Loop in C Program.

While Loop: In This Case programming that you want to do something a fixed number of times. The while loop mostly Cases use for calculate salary of different no.of persons. Convert to temperature from centigrade to Fahrenheit .

Sample Program For While Loop

#include<stdio.h>
int main()
{
int p,n,count;
float r,si;
count=1;
while (count<=3)
{
printf("Enter values p,n,r:\n");
scanf("%d%d%f",&p,&n,&r);
si=p*n*r/100;
printf("Interest = %f",si);
count=count+1;
}
}

For Loop:  The For Loop is Most Popular in looping instruction  c Programming Language . Why For Loop is Popular ? . For loop Having  Three stages Complete at a line.

General Form For Loop Syntax

for ( initial value; test value; increment value )

Sample Program

#include<stdio.h>
int main()
{
int a;
printf("Enter a Values:\n");
scanf("%d",&a);
for (a=a;a<=10;a++)
{
printf("Enter The Value is %d\n",a);
}
}

Nested Loops : The Nested Loop process With in while and for loops in c programming Language.

Sample Program For Nested Loop in For Loop !!

#include<stdio.h>
int main()
{
int r,c,sum;
for(r=1;r<=3;r++) //outer loop
{
for(c=1;c<=2;c++) // inner loop
{
sum=r+c;
printf("r=%d C=%d sum=%d \n",r,c,sum);
}
}
}

Odd Loop : The odd loop using for the far executed the statement with in ten a finite number of times.The odd loop function can be used in below program with do or while methods.

Program For Odd Loop

#include<stdio.h>
int main()
{
char another;
int x;
do{
printf("Enter a Number :");
scanf("%d",&x);
printf("Square of %d Value %d",x,x*x);
printf("\n we want to Enter the Another Number : y/n");
scanf("%c",&another);
}
while(another=='y');
}

Break Statement : The Break Statement is using in loop process jump the out of the loop.

For Example Break Statement in C
                                                                   // prime number Checking
#include<stdio.h>
int main()
{
int num,i;
printf("Enter number");
scanf("%d",&num);
i=2;  // initial value
while( i <=num-1)
{
if(num%i==0)
{
printf("This Number is not Prime ");
break;
}
i++;
}
if(i==num)
printf("prime number");
}

Continue Statement : The Continue Statement is some programming situations. we want to take the control to the beginning of the loop , by passing the statement inside the loop , which have not yet been executed. 
Using Keyword  " continue ".

Sample Programs for continue 

#include<stdio.h>
int main()
{
int i,j;
for(i=1;i<=2;i++)
{
for(j=1;j<=2;j++)
{
if(i==j)
continue;
printf("\n %d %d\n",i,j);
}
}
}

do-While Loop : The  do-while loop like to be while process.( minor difference ) .The While tests the condition before executing any of the statements with in the while loop. as against this , the do-while tests the condition after having executed the statements with in the loop.

Small Program Example For Do-While Loop

While 

#include<stdio.h>
int main()
{
while(4<1)
printf("Welcome");
}

Do -while

#include<stdio.h>
int main()
{
do{
printf("welcome\n");
}
while(4<1);
}

Thanks For Visiting Welcome !! 


nested if else in c

Nested if else statement in c 

Nested if else :  An Entire if else construct within either the body of the if statement or the body of else statement. That is called as " nesting " of ifs.
nested if else alltechprograms

Program For Nested if else

#include<stdio.h>
int main(){
int x;
printf("Enter Only 1 or 2 Numbers:\n");
scanf("%d",&x);
if ( x==1)
printf("Your Enter Number is Equal to 1");
else{
if(x==2)
printf("the number is equal to 2");  
else
printf("the number is not Equal To 1 or 2");
}
}

The above Programs Can be nested if else statement process. If we enter the number is equal to 1 .it's true go to next statement printf().otherwise goes to the else statement, but here can having also if statement. The if statement is true then process to printf(). otherwise else statement is executed. 

Use of Logical Operators in Nested if else

The Logical operators are Process in Nested Else - if statement . The Logical Operator are  &&,  || ,  ! . There are read as  'AND'  'OR'  'NOT'  Respectively.

Program For Logical Operator Using Nested If else Statement in c Program  ( Percentage Problem Solve ).

#include<stdio.h>
int main()
{
int n1,n2,n3,n4,n5,n6,per;
printf("Enter The Marks in 6 Subject:\n");
scanf("%d%d%d%d%d%d",&n1,&n2,&n3,&n4,&n5,&n6);
per=(n1+n2+n3+n4+n5+n6)/6;
if(per>=60)
printf("Good Marks");
else{
if(per>=50)
printf("Average Marks");
else{
if(per>=40)
printf("Bellow Average");
else
printf("Dull");
}
}
}
Nested else if Statement  ( Another Way ) would be Like Bellow Program.
Sample Example Program
Suppose , 
if ( i==2 )                                                       if( i==2)
printf(" Hello ");                                            printf("Hello ");
else{                                                              elseif( j==2 )
if(j==2)                                                         printf("World"); 
printf(" world ");
}

Thanks For Reading More Information Nested If Else. Any Doubts Comment. Like This Post.