You are on page 1of 6

WEEK 11 LAB B

QUESTION 1

INPUT

#include<stdio.h>
struct stu {
char name[50];
int marks1;
int marks2;
}s1;
void sch()
{
    float avg=(s1.marks1+s1.marks2)/2.0;
    if (avg>=85)
    {

        printf("You are eligible for schlarship");


    }
    else
    {
        printf("You are not eligible for schlarship");
    }
}
void main()
{
    printf("Enter the student name: ");
    gets(s1.name);
    printf("Enter the student marks in first year: ");
    scanf("%d",&s1.marks1);
    printf("Enter the student marks in second year: ");
    scanf("%d",&s1.marks2);
    sch();
}

OUTPUT

QUESTION 2

INPUT
#include <stdio.h>

void swap(int , int);

int main()

int a = 10;

int b = 20;

printf("values before swapping = %d, b = %d\n",a,b);

swap(a,b);

printf("values after swapping = %d, b = %d\n",a,b);

void swap (int a, int b)

int temp;

temp = a;

a=b;

b=temp;

printf("After swapping values in function a = %d, b = %d\n",a,b);

OUTPUT
QUESTION 3

INPUT

#include<stdio.h>

void change(int);

void main()

printf("Example for call by value\n");

int a;

printf("Enter the number a:-");

scanf("%d",&a);

change(a);

printf("Value of a: %d",a);

void change(int x)

x+=100;

OUTPUT

#include<stdio.h>
void change(int *x);
void main()
{
    printf("Example for call by reference\n");
    int a;
    printf("Enter the number a");
    scanf("%d",&a);
    change(&a);
    printf("Value of a: %d",a);

}
void change(int *x)
{
    *x+=100;
}
OUTPUT

QUESTION 4

INPUT

#include<stdio.h>

void main()

int var=20;

int *ptr=&var;

printf("Value of ptr %d\n",ptr);

printf("Value of var %d\n",var);

printf("Value of *ptr %d\n",*ptr);

}
OUTPUT

QUESTION 5

INPUT

# include <stdio.h>

int main( )

int a[20],n,i,sml ;

int *ptr ;

printf("total number: ") ;

scanf("%d ",& n) ;

for (i = 0; i < n ; i++ )

printf("enter the number %d:-",i+1);

scanf("%d ",&a[i]) ;

ptr++ ;
}

ptr = & a[0] ;

sml = a[0] ;

for (i = 0; i < n ; i++ )

if ( sml > ( *ptr ))

sml = *ptr ;

ptr++ ;

printf("\n Smallest element is : %d",sml) ;

return ( 0 );

OUTPUT

You might also like