QUOTE OF THE DAY..

“The mediocre teacher tells. The good teacher explains. The superior teacher demonstrates. The great teacher inspires.”
― William Arthur Ward
Share this Post Share to Facebook Share to Twitter Email This Pin This

programming questions - simple


PROVIDING CLASSES FOR
COMPUTER SCIENCE (O-A LEVEL/BCA/BTECH/MCA) [ C , C++ , DATA STRUCTURE,DBMS, COMPUTER ORGANIZATION  & ARCHITECTURE, OPERATING SYSTEM, COMPUTER NETWORKS (DCN), TCP/IP, SOFTWARE ENGINEERING, SOFTWARE PROJECT MANAGEMENT, COMPUTER GRAPHICS, STRUCTURED SYSTEM ANALYSIS & DESIGN(SSAD), SYSTEM SOFTWARE/PROGRAMMING, UNIX, DATAWAREHOUSE & DATA MINING, ADVANCE OS (DISTRIBUED), MANAGEMENT INFORMATION SYSTEM (MIS), CG UNDER C/C++, PROJECT DESIGINING IN C/C++. PROJECTS IN C/C++ ARE ALSO AVAILABLE]

NOTES  ON-       _c - language______        _SIMPLE QUES      
Q 1  SWAPPING  OF  TWO  NUMBERS -  CALL BY VALUE
 A  // call by value
#include<conio.h>
#include<stdio.h>
void swap(int a,int b)
{
int c;
c=a;
a=b;
b=c;
printf("\n  \n Value of a  and b  in the function : %d  %d " , a ,b);
}

void main()
{
int a,b;
clrscr();
printf("\n  \n Enter two numbers : - ");
scanf("%d%d",                              &a,&b);
printf("\n  \n values of a and b before calling the function:  %d  %d ",a, b);
swap(a,b);
printf("\n \n  values of a and b after calling the function:   %d  %d ",a, b);
getch();
}

Q 2 ) SWAPPING  OF  TWO  NUMBERS   -  CALL BY  REFRENCE
A   // call by refrence            
#include<conio.h>
#include<stdio.h>
void swap(int *x,int *y)
{
int c;
c=*x;
*x=*y;
*y=c;
printf("\n Value of a= %d  b= %d  in function  ",*x,*y);
}

void main()
{
int a,b;
clrscr();
printf("\n Enter two numbers : - ");
scanf("%d%d",&a,&b);

printf("\n Value of a= %d  b= %d  in main before calling ",a,b);
swap(&a,&b);
printf("\n Value of a= %d  b= %d  in main after calling ",a,b);
getch();
}


Notes  compiled  by  neha gupta

Q 3  USE  OF  SIZEOF()  OPERATOR...
  A  #include<conio.h>
#include<stdio.h>
void main()
{
 int a[5],b;
 char h;
 clrscr();
//  calculating the size of integer array a[5]
 b= sizeof(a);
 printf("\n Size of  a  is  :-=   %d ",b);

//    calculating the size of  char variable h
 b= sizeof(h);
 printf("\n Size of  a  is  :-=   %d ",b);
 getch();
}


Q4 macro

#include<stdio.h>
#include<conio.h>
#define MAX 5
void main()
{
    int ar[MAX],i,sum;
    clrscr();
    printf("\nEnter %d Nos. :",MAX);
    for(i=sum=0;i<MAX;i++)
    {
            printf("\nEnter Element :");
            scanf("%d",&ar[i]);
            sum+=ar[i];
    }
    printf("\nArray Elements :");
    for(i=0;i<MAX;i++)
            printf("\n%d",ar[i]);
    printf("\nSum of elements :%d",sum);
    getch();
}