Jan

23

#include<stdio.h>
#include<conio.h>
main() {
int a[10][10],i,j,k,n,m,min,max,col=0,flag=0,sad=0;
clrscr();
printf(“enter order m,n of mxn matrix”);
scanf(“%d %d”,&m,&n);
printf(“enter elements row-wise”);
for(i=0;i<m;i++)  {
for(j=0;j<n;j++)     {
scanf(“%d”,&a[i][j]);
}
}
printf(“\n given matrix is \n\n”);
for(i=0;i<m;i++) {
for(j=0;j<n;j++)
{
printf(“%d\t”,a[i][j]);
}
printf(“\n”);
}

for(i=0;i<m;i++) {
min=a[i][0];
for(j=1;j<n;j++)  {
if(a[i][j]==min)      {
flag=1;
}
if(a[i][j]<min)    {
min=a[i][j];
col=j;
flag=0;
}
}
if(flag==1)
printf(“\n no saddle point for row %d”,i+1);
if(flag==0)       {
max=a[0][col];
for(k=1;k<m;k++)  {
if(a[k][col]==max)   {
flag=1;
break;
}   else   {
if(a[k][col]>max)    {
max=a[k][col];
}
}
}
if(max==min && flag !=1)
{
printf(“\n saddle pt.at (%d,%d)”,i+1,col+1);
sad=1;
}
}   // flag=0;

}
if(sad==0)
printf(“\n no saddle poit in matrix “);

getch();

}

Jan

17

#include<stdio.h>
#include<conio.h>
void main(int argc, char *argv[]){
int i;
printf(“\n%d”,argc);
for (i=0;i<argc;i++)
printf(“\n%s”,*(argv+i));
}

Filled Under: C Programming

Jan

17

#include<conio.h>
#include<stdio.h>
#define N 0
#define Title “ABC”
#ifdef N
#define N 100
#else
#define N 200
#endif
void main(){
printf(“N=%d \n”,N);
printf(“Title=%s \n”,Title);
}

 

———————————————————————————————-

 

#include<conio.h>
#include<stdio.h>
#define N ‘A’
#define BEGIN void main() {
#define END }

BEGIN
printf(“N= %c\n”,N);
END

————————————————————————————————

 

//d2.c

#include<conio.h>
#include<stdio.h>
#define N ‘A’
#define BEGIN void main() {
#define END }
void show(){
printf(“void show”);
}

 

——————————————————————————————————–

 

#include “d2.c”
BEGIN
show();
printf(“\nN= %c “,N);
END

Filled Under: C Programming

Jan

17

#include<conio.h>
#include<stdio.h>
int power(int,int);

void main(){
int x,n,result;
printf(“Enter number : “);
scanf(“%d”,&x);
printf(“Enter power : “);
scanf(“%d”,&n);
result=power(x,n);
printf(“Power is: %d”,result);
}
int power(int x,int n){
if (n==1)
return x;
else
return (x*power(x,n-1));
}

Filled Under: C Programming

Jan

17

#include<conio.h>
#include<stdio.h>
int fac(int);
void main(){
int num;
printf(“Enter number to get factorial: “);
scanf(“%d”,&num);
num=fac(num);
printf(“Sum is: %d”,num);
}
int fac(int n){
if (n==1)
return 1;
else
return (n*fac(n-1));
}

Filled Under: C Programming

Jan

17

#include<conio.h>
#include<stdio.h>
int sum(int);
void main(){
int num;
printf(“Enter number to get num till: “);
scanf(“%d”,&num);
num=sum(num);
printf(“Sum is: %d”,num);
}
int sum(int n){
if (n==1)
return n;
else
return (n+sum(n-1));
}

Filled Under: C Programming

Jan

17

#include<conio.h>
#include<stdio.h>
#include<alloc.h>
void main(){
int *intPtr,*intPtr2,i;
intPtr=(int*) calloc(15,sizeof(int));
intPtr2=(int*) malloc(15*sizeof(int));
intPtr=realloc(intPtr,20);

//for(i=0;i<5;i++)
//scanf(“%d”,intPtr+i);

for(i=0;i<15;i++){
printf(“Integers: %d\n”,*(intPtr+i));
}

for(i=0;i<5;i++)
scanf(“%d”,intPtr2+i);

for(i=0;i<15;i++){
printf(“Integers: %d\n”,*(intPtr2+i));
}
free(intPtr);
free(intPtr2);
}

—————————————————————————————–

#include<conio.h>
#include<stdio.h>
#include<alloc.h>
void main(){
char *charPtr;
int count=0;
charPtr=(char*) malloc(10*sizeof(char));

scanf(“%s”,charPtr);
printf(“String: %s\n”,charPtr);

while(*charPtr!=’\0′){
printf(“%c\n”,*charPtr);
charPtr++;
count++;
}
printf(“\nLength = %d\n”,count);
free(charPtr);
}

Filled Under: C Programming

Jan

17

#include<conio.h>
#include<stdio.h>
void main(){
int a=25,b=10;
void add20(int x,int y);
void add20ref(int *x,int *y);
printf(“\n Before function call by val a=%d  b=%d”,a,b);
add20(a,b);
printf(“\n After function call by val a=%d  b=%d”,a,b);
printf(“\n\n Before function call by ref a=%d  b=%d”,a,b);
add20ref(&a,&b);
printf(“\n After function call by ref a=%d  b=%d”,a,b);
}
void add20(int x,int y){
x=x+20;
y=y+20;
printf(“\n Inside the function a=%d  b=%d”,x,y);
}
void add20ref(int *x,int *y){
*x=*x+20;
*y=*y+20;
printf(“\n Inside the function a=%d  b=%d”,*x,*y);
}

Filled Under: C Programming

Jan

17

#include<conio.h>
#include<stdio.h>
void main(){
int a,b;
int s,*aptr,*bptr;
printf(“\n Enter Two integers: “);
scanf(“%d%d”,&a,&b);
aptr=&a;
bptr=&b;
s=*aptr+*bptr;

printf(“\n Sum = %d”,s);
printf(“\n &a = %d”,&a);
printf(“\n &b = %d”,&b);
printf(“\n &aptr = %d”,&aptr);
printf(“\n aptr = %d”,aptr);
printf(“\n *aptr = %d”,*aptr);
getch();
}

Filled Under: C Programming

Jan

17

#include<conio.h>
#include<stdio.h>
void main(){
int num1,num2,*big;
int *ptr1,*ptr2;
printf(“Enter two numbers: “);
scanf(“%d%d”,&num1,&num2);
ptr1=&num1;
ptr2=&num2;
if(*ptr1>*ptr2){
big=ptr1;
}
else{
big=ptr2;
}
printf(“Max is %d=”,*big);
getch();
}

Filled Under: C Programming

Jan

17

#include<conio.h>
#include<stdio.h>

struct emp{
int eno;
char ename[50];
float sal;
};
struct emp get(){
struct emp e;
printf(“Emp No: “);
scanf(“%d”,&e.eno);
printf(“Emp Name: “);
scanf(“%s”,e.ename);
printf(“Emp Sal: “);
scanf(“%f”,&e.sal);
return e;
}
void disp(struct emp e){
printf(“Emp No: %d\n”,e.eno);
printf(“Emp Name: %s\n”,e.ename);
printf(“Emp Sal: %f\n”,e.sal);
}
void main(){
struct emp e[5];//={1,”RGG”,500};
int i;
for(i=0;i<=1;i++){
printf(“Emp No: “);
scanf(“%d”,&e[i].eno);
printf(“Emp Name: “);
fflush(stdin);
gets(e[i].ename);
printf(“Emp Sal: “);
scanf(“%f”,&e[i].sal);
}
for(i=0;i<=1;i++)
disp(e[i]);
/*(em=get();
disp(em);
*/
}

Filled Under: C Programming

Jan

17

#include<conio.h>
#include<stdio.h>
typedef int integer;
struct emp{
int eno;
char ename[50];
int sal;
};
void main(){
struct emp e;
integer i;
for(i=1;i<=10;i++)
printf(“%d\n”,i);
}

Filled Under: C Programming

Jan

17

#include<stdio.h>
main(){
int i;
char name[];

//char name[]={‘H’,’E’,’L’,’L’,’O’,’H’,’E’,’L’,’L’,’O’,’H’,’E’,’L’,’L’,’O’,’\0′};
gets(name);
for(i=0;name[i]!=’\0′;i++){
printf(“%c”,name[i]);
}
printf(“\n%d\n”,strlen(name));
puts(name);
getch();
}

Filled Under: C Programming