Archive for c programs and solutions

You are browsing the archives of c programs and solutions.

Important programs in C language part-I

/*2D array*/

 
#include<stdio.h>
#include<conio.h>
void main()
{
 
int a[3][3],i,j;
clrscr();
printf("Enter the array elements");
for( i= 0;i<=2;i++)
{
for(j=0;j<=2;j++)
{
scanf("%d",&a[i][j]) ;
}
}
printf("The elements of the array are");
for( [...]

c plus plus programs and answers

30. What is an action class?
Answer:
The simplest and most obvious way to specify an action in C++ is to write a function. However, if the action has to be delayed, has to be transmitted ‘elsewhere’ before being performed, requires its own data, has to be combined with other actions, etc then it often becomes [...]

frequently asked c pp programs

146)

main()
{
static int a[3][3]={1,2,3,4,5,6,7,8,9};
int i,j;
static *p[]={a,a+1,a+2};
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
printf("%d\t%d\t%d\t%d\n",*(*(p+i)+j),
*(*(j+p)+i),*(*(i+p)+j),*(*(p+j)+i));
}
}

Answer:
1 1 1 1
2 4 2 4
3 7 [...]

C Aptitude progams

All the programs are tested under Turbo C/C++ compilers.
It is assumed that,

Programs run under DOS environment,
The underlying machine is an x86 system,
Program is compiled using Turbo C/C++ compiler.

The program output may depend on the information based on this assumptions (for example sizeof(int) == 2 may be assumed).
Predict the output or error(s) for the following:
1.

[...]