Friday, September 18, 2015

PRINT STAR PATTERN IN VB.NET USING NESTED FOR LOOP




No of operand= row, col, noofrow
Row printing range= 1 to 5
Column printing range = 1 to row

Given program is -

Option Strict On
Module Module1
    Sub Main()
        Dim row, col, noofrow As Integer
        noofrow = 5
        For row = 1 To noofrow Step 1
            For col = 1 To row Step 1
                Console.Write("*")
            Next
            Console.Write(vbNewLine)
        Next
End Module
 

RULE OF IDENTIFIER


RULE OF IDENTIFIER
1.   First character must be an alphabet or underscore.
2.   Must consist of only letter, digit or underscore.
3.   Only first 31 characters are significant.
4.   Cannot use a keyword.
5.   Must not contain white space.

Thursday, September 17, 2015

VARIABLE LIFE CYCLE


        Variable is container. It contains value according to data type.
        Variable Life Cycle.
        1. Declaration of the identifier.
        2. Initialize value inside the identifier.
        3. Perform some operation. (According to question)
        4. Print identifier value.
      

        Syntax for (1) Identifier Declaration
        <data type> <space> <identifier name >;
        Example:-
        int roll;

        Syntax for (2) Initialize value inside the identifier.
        <identifier> <assignment operator> <value >;
        Example:-
        roll=1001;
        Syntax for (4) Print identifier value.
        <name of the output function > <("<format specifier>", <identifier as a argument >)>;
        Example: -
        printf("%d",roll);
        Syntax for (4) Print identifier value with message.
        <name of the output function> <("<message><format specifier>",<identifier as a argument>)>;
        Example:-
        printf("Roll=%d",roll);
        .........................................................................................................
       

To declare more than one variable with same data then use comma operator to separate each identifier.
        Syntax for - More than one variable with same data type.
        <data type> <space> <identifier><comma><identifier><comma> ................ ;
        Example: -
        int fnumber,snumber;
        To print more than one identifier value
        syntax:-
      <name of the output function> <("<format specifier><format specifier>",<identifier as a argument><identifier as a argument>)>;
        Example: -
                     printf("Fnumber=%d\nSnumber=%d",fnumber,snumber);

Monday, January 3, 2011

#include
#include
# include
void main()
{
int i,j,f,att,a,b=0,c,d;
char g,h,n,pass[50]="1234";
clrscr(); p:
printf("\n enter the password");
for(i=0;pass[i]!='\0';i++);
for(f=0,j=0;j {
g=getch();
printf("*");
if(g!=pass[j])
f=1;
if(f==0)
{
clrscr();
printf("\n welcome to the program");
printf("\n enter the no : ");
scanf("%d",&a);
printf("\n press 1 for reverse");
printf("\n press 2 for palindrome");
printf("\n press 3 for armstrong ");
printf("\n press 4 for exit");
fflush(stdin); scanf("%c",&n);
if(n=='1')
{
while(a>0)
{
c=a%10;
b=(b*10)+c;
a=a/10;
}
printf("\nreverse=%d",b);
}
if(n=='2')
{
d=a;
while(a>0)
{
c=a%10;
b=(b*10)+c;
a=a/10; \
}
if(b==d)
printf("\n palindrome");
else printf("\n not palindrome");
}
if(n=='3')
{
d=a;
while(a>0)
{
c=a%10;
b=b+c*c*c;
a=a/10;
}
if(b==d)
printf("\n armstrong");
else
printf("\n not armstrong");
}
if(n=='4')
{
exit(0);
}
}
else
printf("\n invalid passward");
printf("\ndo u want to try again");
printf("\n press y/n : ");
fflush(stdin);
scanf("%c",&h);
att=1;
while(h=='y')
{
if(att<=3)
{
printf("\n renter the passward");
att++;
goto p;
}
else
printf("sorry ur passwad doesn't match");
}
getch();
}