Saturday 8 December 2012

How to develop logic in c programming language with programs

How to develop logic in c programming language with programs

C Language  is First  Programming Language.
I Can say it is base of all Programming Language.
To develop the code in Java ,c# , VB , c++ ,Or any Language we need C.
I am not saying that only C is language where you can apply  your all logic but if you will apply then it
will be good.
If  you want to develop logic in c language then you have to learn Simple Programs ..
i.e .
Even - Odd Number.
Prime - Perfect Number.
Armstrong Number.
series of perfect and prime number.
By playing with loops you can improve logic in good way ..
Like
For loop ,
If - Else,
while loop..
goto statement
switch statement

C language gives you idea about ,How to write program using  Array ,Pointers, Structure.
Main thing is that you should know how to declare the variables and  how to initialize them..
How to create a  function and how to call the function which you have already created.
While writing the program , writing comments is also nice idea.

By Using Turbo C Just Use F7 key to check step by step execution .

Pyramid pattern in c program | to print pyramid | comments with for loop

Pyramid pattern in c program | to print pyramid | comments with for loop

In this program we are going to learn how to print  triangle in pyramid  pattern in c program using two for loop.so ,Basically there are two types of pyramid
1->Floyd triangle
2->Pascal triangle.

structure for pyramid

                                t
                               t  t
                             t t  t  t
                            t  t  t  t  t
void main ()// source code
{

int i,j,n;
clrscr();
printf("Enter number of lines\n");
scanf("%d",&n);
for(i=1;i<=n;i++)//loop for number of lines
{
 for(j=0;j<40-i;j++) //for printing spaces
{
printf(" ");
}
 for(j=i;j<=2*i-1;j++)//for printing trinagle on left half
 {
 printf("%d",j%10);
}
for(j=2*i-2;j>=i;j--)//for printing triangle on right half
{
printf("%d",j%10);
}
printf("\n");
}
getch();
}

another way also is there

Another pattern  with source code
* * * * *
* * * *
* * *
* *
*
*/

#include<stdio.h>
int main()
{
int i,j,n;

printf("Enter no. of lines: ");
scanf( "%d",&n);


//for loop for number of lines
for(i=n;i>=1;i--)
{

//for printing stars
for(j=1;j<=i;j++)
 {
printf("* ");
 }
 printf("\n");
}
return 0;
}

so , basically we need two for loops .first for loop for printing number of lines .
How many lines do you need .
then after print one simple star we need to give space for that we need third for loop.
After that triagle for left half and right half.

goto statement in c program | simple goto example in c

goto statement in c program | simple goto example  in c

In this article we are going to learn how to work with goto statement in c programming language.
Basically goto is jump statement which means we can go one point or functionality to another functionality  in same function or within function. for  that we use goto statement.

#include<stdio.h> // including header files
#include<conio.h>
void main()
{
int n;
clrscr();
printf("Enter the no");
scanf("%d",&n);
if(n % 2==0)
goto even;  // will goto even
else
goto odd;
even:printf("even"); // will print if number is even
odd:printf("odd");
getch();

Addition of two numbers in c program with source code.

Addition of two numbers in c program with source code.


In this article we are going to learn how to add two number entered by user in c programming language using function.
create function  and initialize that function and call that function by passing parameter you want to add.

#include<stdio.h>
void main()
{
  int a,b;
  clrscr();
  printf("\n Enter 2 Number:"); // user will enter two number one by one
  scanf("%d %d",&a,&b); // number will store in variable a and b.
  printf("\Addition=%d",add(a,b)); //calling  function add
}
  int add(int x,int y)  // in function add passed two parameter x and y.
  {
    return(x+y);  // adding two number
  }
return will  give output.

Thursday 6 December 2012

Palindrome program | logic | examples source code | c++

Palindrome  program | logic | examples source code | c++

After reversing if  you are getting same  number it means you are reversing palindrome number.
to reverse the all digit and get same number is symbol of palindrome number.
Lets take examples
121  after reverse it  we will get 121. so we can say 121 is palindrome number.same is with 999=999.
12=21 not palindrome number .Have you seen mirror same functionality is working here.
But here is digit not your  face.so we are going to learn about palindrome number and execution.
we  can reverse string also like did=reverse(did)=did but i dont know about  words just think about digits .ok i think there is enough explanation now time is to do something real .
Let's concentrate to source code in c program.sorry about c language we are going to learn c++.everything is same in c just little about scanf and printf

How to write c++ palindrom number Program with source code


int pali(int);  // function name pali
void main()
{
int n,a;
clrscr();
cout<<"\n enter the number=";
cin>>n;  // accepting number from user
a=palindrom(n);
if(n==a)  // cheking after reversing number is same or not
cout<<"\n number is palindrom";  // yes it is
else
cout<<"\n number is not palindrom";  //no  it is not
getch();
}
int palindrom(int x) //
{
int r,sum=0;
while(x!=0) // till number will there
{
r=x%10; taking mode so we can get at least one number

sum=sum*10+r;   //addition
x/=10; //division
}
return(sum);//function calling
}

in  c or c++ do execution with your own .execution will give you correct logic and method to understand program logic.

This application is currently offline. To enable the application, remove the app_offline.htm file from the application root directory.

This application is currently offline. To enable the application, remove the app_offline.htm file from the application root directory.

This application is currently offline. To enable the application, remove the app_offline.htm file from the application root directory.
  1. when error comes like this after executing  asp.net website.
  2. simple way to get rid of this problem is just remove app_offline.htm.
  3. how to remove app_offline.htm file  the question comes .
  4. whenever this query will comes just go to solution explorer and delete app_offline.htm file.
  5. after deleting that file just again refresh website and press F5 to run the program again.

Queristring in vb.net with example | how to use queristring in asp.net

Queristring in vb.net with example | how to use queristring in asp.net

how to use queristring in vb.net .
if we want to pass the information from one page to another IN  .aspx page
in c# or vb.net we need some object which will give flow of data from
one page to another page.so , that is session and queristring.
in this article we will learn how to use response.redirect  to pass data from one page to another page.
Response.Redirect("Default.aspx?from=" & txtfrom.Text & "  &to=" &
txtto.Text & " &last=" & txtlast.Text)
 queristring do same functionality in c# and vb but using syntax is little bit different.
in c# we use + sign whereas in vb we use & sign.
Response.Redirect("Default2.aspx?from=" & txtfrom.Text & "  &to=" &

txtto.Text & " &last=" & txtlast.Text)

above code shows that passing value from first default.aspx to
default2.aspx. where variable from is storing data of txtfrom text box
and to is storing txtto text box value .this value will go to the
default2.aspx where we can utilize that values.

so lets start page 2 default2.aspx.
 we can store from and to value in other variable for use purpose.
 Dim sr as integer
sr=from
Dim dr as integer
dr=to

and we can use it any where on same page .
but remember about  " " and & & sign . many developers like me find difficulties to solve this problem.

basic problem comes when we need to pass more than one paramater then we think about syntax  like where to use & and  '" and "","".
there are very small , simple and very useful think. so , do it very carefully. Don't play with it just work with it.


Tuesday 4 December 2012

strcmp | How to check password in C with Break Statement and while

strcmp  |  How to check password in C with Break Statement and while

I don't have so much idea about its execution but at last its using strcmp to compare
original password and entered password by using f7 key you can get its idea .

#include<stdio.h> //initializing header files
#include<conio.h>
void main()
{
void pass();  // function name pass
clrscr();
pass();
printf("\n\nNow you can proceed...........\n");
getch();
}
void pass()
{
char ar[30],ch; //
int i=0;
printf("\n\nEnter password\n");
while(1)
{
ch=getch();
if(ch==13)
break;
else
{
ar[i]=ch;
i++;
printf("*");
}
}
ar[i]='\0';
if(strcmp(ar,"yourvalue")==0)
return;
else
{
printf("Invalid password try again\nPress any key to continu\n");
getch();
pass();
}
}

c program for positive (+ve)and negative(-ve) number | comments with source code example

c program for positive (+ve)and negative(-ve) number | comments with source code example

Positive number means number which is not negetive means number greater than 0 or equal to zero.
let's take example.
9 - 8=1
After subtracting 8 from 9 we will get out put =1 that is positive.
but if i will subtract 9 from 8 like 8 - 9= -1.
i will get out put like -1.
go to start -> run  -> calc .
it will open calci and then  you can calculate.or do any kind of calculation.so , in this program i am going to show  How to find out positive and negative number.
with comments in c program with source code.at last output.

#include<stdio.h>    //header files//
#include<conio.h>   //for clrscr//
main()
{                           //main start//
int user_number;       //declaration//
clrscr();                    //clear the screen//
printf("enter any number"); //taken number from user//
scanf("%d",&number);
//condition//

if(user_number>0)  //if user number is Greater than zero//
{
printf("\n the given number  is positive");
}

if(user_number<0) //if user number is Less than zero//
{
printf("\n the given number  is negetive");
}
getch();
}               //Let see the out-put
output is
enter any number 68
number  is positive

enter any number -56
a is negative