07 October, 2014

C Pointers With Examples Programs



C Pointers With  Examples Programs


1.What Is The Output Of The Program?
#include <stdio.h>
int main ()
{
    int a = 10;
    int *p = &a;
    printf ("%d %d\n", a, *p);
    (*p)++;
    printf ("%d\n", a);
    ++(*p);
    printf ("%d\n", a);
   return 0;
}

Ans:10 10
         11
         12


2. What Is The Output Of The Program?

#include <stdio.h>


int main ()
{

    int array [5] = {5, 4, 3, 2, 1};

    int *pointerVariable;

    pointerVariable = array;

    printf ("%d", *pointerVariable);

    printf ("%d", ++*pointerVariable);

    printf ("%d", *++pointerVariable);

    printf ("%d", ++*++pointerVariable);

    return 0;

}

Ans:5644

3. What Is The Output Of The Program?
int main ()
{
    int *p, i;

    i = 5;

    p = &i;

    printf ("%d", *p);

    printf ("%d\n", i**p);

    printf ("%d\n", i**p*i+*p);

    return 0;
}

Ans:5 25 130


4. What Is The Output Of The Program?
#include <stdio.h>
int main ()
{
    int a, b, c, *p, *q, *r;

    a = 10;     b = 20;     c = 30;

    p = &a;     q = p;

    printf ("%d\n", *q);

    (*p)++;

    printf ("%d\n", *p);

    printf ("%d\n", *q);

    r = q;

    r++;

    printf ("%d\n", *q);

    r--;

    printf ("%d\n", *r);

    (*q)++;

    printf ("%d\n", *r);

    return 0;
}

Ans:10
11
11
11
11
12

5. What Is The Output Of The Program?
#include <stdio.h>
void changeValue(int *p)
{
    (*p)++;
}

int main ()
{
    int a = 10;
    int b = 20;

    changeValue(&a);

    printf ("%d %d\n", a, b);

    changeValue(&b);

    printf ("%d %d\n", a, b);

    }

Ans:11 20
 11 21

6. What Is The Output Of The Program?

void changeValue (int *p, int q)
{
    q = *p + 1;
    (*p)++;
    p++;
}

int main ()
{
    int p, q;
    p = 10;     q = 20;

    changeValue(&p, q);

    printf ("%d %d\n", p, q);

    changeValue(&q, p);

    printf ("%d %d\n", p, q);

    return 0;
}

Ans: 11 20
11 21

7. What Is The Output Of The Program?
int main ()
{
    int array [5] = {5, 4, 3, 2, 1};

    printf ("%d\n", *array);

    printf ("%d\n", *array + 1);

    printf ("%d\n", *(array + 2));

    return 0;
}


Ans: 5
6
3


8. What Is The Output Of The Program?

#include <stdio.h>
int main () {

    int *p, **q;

    int a = 10;

    p = &a;

    q = &p;

    (*p)++;

    (**q)++;

    printf ("%d\n", a);

    return 0;
}


Ans:12

02 October, 2014

Return value of printf() function in C

Return value of printf() function in C


Ans:
A function always returns a value and printf function returns the number of characters successfully printed.


main() 
{ 
int s=1; 
printf("%d",printf("%d %d %d", s,s,s)); 
}
In this above program the inner printf is first called which prints value of s, three times with space between each value, 1 1 1.
Total 5 characters get printed = 3 values and 2 spaces).
As explained earlier the inner printf after printing the values, returns the number of characters printed, 5 which is printed by the outer printf.
The output of the above program is
1 1 1 5


RUNNING ANT BUILD.XML GETTING: JAVA VIRTUAL MACHINE LAUNCHER: COULD NOT FIND THE MAIN CLASS. PROGRAM WILL EXIT



sol:
1) Is the path to java bin directory set properly?? (To check this you need to write command javac in command prompt(cmd) and you will get a list of instructions on cmd console)

 how to set properly bin &pathsetup click here step by step

21 September, 2014

BRM System Architecture

BRM System Architecture

BRM System Architecture consists 4 Tiers:
  • Application Tier
  • Connection Management Tier
  • Data Management Tier
  • Data Tier
fig:BRM System Architecture

 

15 September, 2014

Most Of The C programming Interview Quesitions With Answers



1.    1. Write a c pgm to print 1 to 100 without using loops.


ANS:1 -100 without looping....

#include
#include
int i=1;
void main()
{
i<=100 ? printf("%d\n",i) : getch(); //conditional operator
i++;
main(); //recursive calling of main() function
}




2.

  Write a c pgm for leap year

#include
int main(){
      intyear;
      printf("Enter a year: ");
      scanf("%d",&year);
      if(year%4== 0)
      {
          if(year%100== 0)/* Checking for a century year */
          {
              if( year%400== 0)
                 printf("%d is a leap year.", year);
              else
                 printf("%d is not a leap year.", year);
          }
          else
             printf("%d is a leap year.", year );
      }
      else
         printf("%d is not a leap year.", year);
      return0;
}


1.    
4.
  Wr 3. fibbonacci series


basic and simple logic fabbonacci series:

#include
#include
void main()
{
int a=1,b=-1,c,n;
printf("enter the no. of terms :");
scanf("%d",&n);
for(int i=1;i<=m;i++)
{
c=a+b;
printf("%d\n",c);
b=a;
a=c;
}
getch();
}


4.write a c pgm for factorial
Factorial :

#include
#include
void main()
{
int m,j=1;
printf("enter ur number :");
scanf("%d",&m);
for(int i=1;i<=m;i++)
j=j*i;
printf("the factorial is : j");
getch();
}



5. Write a c pgm count no of lines , blanks, tabs in a

para(File concept)
#include

void main()
{
FILE *FP;
char Ch;
int l=o,b=0,t=0,p=0;
FP = fopen(filename, mode);
while (FP) {
if(ch==EOF)
break;
l++;
if(ch==" ")
b++;
if(ch=="\n")
p++;
if(ch=="\t")
t++;
fclose(fp);
display counts;
getch();
}
 

6. Write a c pgm to print the letter as per given condition
      i.e.. if u give 4
    out put should b
    4 4 4 4
    4 4 4 4
    4 4 4 4
    4 4 4 4


printing ur sequence:

#include
#include
void main()
{
int m;
printf("enter ur number:");
scanf("%d",&m);
for(int i=1;i<=m;i++)
{
for(int j=1;j<=m;j++)
printf("%d ",m);
printf("\n");
}
getch();
}



7.how do get the o/p in number from 1 to 100 in the screen
without using    control statement?

ANS:printing 1-100 without using loops as well as control statement.


#include
#include
int i=1;
void main()
{
i<=100 ? printf("%d\n",i) : getch(); //conditional operator
i++;
main(); //recursive calling of main() function
}


//conditional operator is not a control statement


8. who do u print the word "hello world" without using
"printf" statement?

ANS:printing a string without printf()

#include
#include
void main()
{
if(printf("hello world"))
getch();
}